org.simpleflatmapper.reflect.Getter类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(123)

本文整理了Java中org.simpleflatmapper.reflect.Getter类的一些代码示例,展示了Getter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Getter类的具体详情如下:
包路径:org.simpleflatmapper.reflect.Getter
类名称:Getter

Getter介绍

[英]Interface representing a Getter of a property of type P on a object of type T.

use ObjectGetterFactory to instantiate.
[中]接口,表示T类型对象上P类型属性的Getter。
使用ObjectGetterFactory进行实例化。

代码示例

代码示例来源:origin: arnaudroger/SimpleFlatMapper

public Object[] build(S source) throws Exception {
  Object[] args = new Object[getters.length];
  
  for(int i = 0; i < args.length; i++) {
    args[i] = getters[i].get(source);
  }
  
  return args;
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public Byte get(T target) throws Exception {
    return delegate.get(target);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public Float get(T target) throws Exception {
    return delegate.get(target);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public T newInstance(S s) throws Exception {
    return getter.get(s);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public Character get(T target) throws Exception {
    return delegate.get(target);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public P get(T target) throws Exception {
    P p = delegate.get(target);
    
    if (p == null) return defaultValue;
    
    return p;
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public BigInteger get(final ResultSet target) throws Exception {
  String val = getter.get(target);
  if (val == null) return null;
  return new BigInteger(val);
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public UUID get(final R target) throws Exception {
  final String o = stringGetter.get(target);
  return UUID.fromString(o);
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public String get(GettableByIndexData target) throws Exception {
    return String.valueOf(getter.get(target));
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public E get(final R target) throws Exception {
  final String o = stringGetter.get(target);
  return (E) Enum.valueOf(enumType, String.valueOf(o));
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public Calendar get(ResultSet target) throws Exception {
  Date d = dateGetter.get(target);
  if (d != null) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(d);
    return cal;
  }
  return null;
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public E get(final R target) throws Exception {
  final Object o = getter.get(target);
  if (o instanceof Number) {
    return values[((Number) o).intValue()];
  } else {
    return (E) Enum.valueOf(enumType, String.valueOf(o));
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public void set(T target, P value) throws Exception {
    setter.set(target, getter.get(value));
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public void mapTo(final S source, final T target, final MappingContext<? super S> mappingContext) throws Exception {
  final P value = getter.get(source);
  setter.set(target, value, mappingContext);
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@SuppressWarnings("unchecked")
  @Override
  public GenericBuilder<S, T> newInstance(S o, MappingContext<? super S> o2) throws Exception {
    Object value = getter.get(o);
    
    BiInstantiator<S, MappingContext<? super S>, GenericBuilder<S, T>> instantiator = instantiators.get(value);
    
    if (instantiator == null)
      throw new IllegalArgumentException("No discrimator matched " + value);
    return instantiator.newInstance(o, o2);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public T apply(S1 s1, S2 s2) {
  try {
    return getter.get(s1);
  } catch (Exception e) {
    return ErrorHelper.rethrow(e);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public boolean test(S s) {
  try {
    return predicate.test(getter.get(s));
  } catch (Exception e) {
    return ErrorHelper.rethrow(e);
  }
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
  public void set(O target, P value) throws Exception {
    subProperty.getSetter().set(ownerProperty.getGetter().get(target), value);
  }
};

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Override
public int map(PreparedStatement ps, T value, int columnIndex, Context context) throws Exception {
  C collection = collectionGetter.get(value);
  int size = sizeGetter.getInt(collection);
  for(int i = 0; i < size; i++) {
    setter.set(ps, indexedGetter.get(collection, i), columnIndex + i + 1, context);
  }
  return size;
}

代码示例来源:origin: arnaudroger/SimpleFlatMapper

@Test
public void testJavaOffsetDateTime() throws Exception {
  final OffsetDateTime offsetDateTime = OffsetDateTime.now();
  when(resultSet.getObject(1)).thenReturn(offsetDateTime, (OffsetDateTime) null);
  Getter<ResultSet, java.time.OffsetDateTime> getter = factory.<java.time.OffsetDateTime>newGetter(java.time.OffsetDateTime.class, key(Types.TIMESTAMP_WITH_TIMEZONE));
  assertEquals(offsetDateTime, getter.get(resultSet));
  assertNull(getter.get(resultSet));
}

相关文章

Getter类方法