public static <X, Y> PropertyPathExpression<X, Y> getExpression( Class<X> source, String propertyPath) { return getExpression(source, propertyPath, (Class<Y>) null); }
public static <X, Y> Y getNullSafeValue(X target, String propertyPath) { return getNullSafeValue(target, propertyPath, null); }
public static <X, Y> Y getValue(Class<X> source, X target, String propertyPath) { return getValue(source, target, propertyPath, (Class<Y>) null); }
public static <X, Y> PropertyPathExpressionValueHolder<X, Y> getValueHolder( Class<X> source, X target, String propertyPath) { return getValueHolder(source, target, propertyPath, (Class<Y>) null); }
@SuppressWarnings("unchecked") public PropertyPathExpressionValueHolder(X source, String propertyPath) { this(source, (PropertyPathExpression<X, Y>) ExpressionUtils .getExpression(source.getClass(), propertyPath)); }
public static <X, Y> Y getNullSafeValue(Class<X> source, X target, String propertyPath) { return getNullSafeValue(source, target, propertyPath, (Class<Y>) null); }
public static <X, Y> Y getValue(X target, String propertyPath) { return getValue(target, propertyPath, null); }
/** * Constructs a LazyGetterMethod object for the given source object and * field names as a string separated by '.' (dots). Using this constructor * is equal to # * {@link LazyGetterMethod#LazyGetterMethod(java.lang.Object, java.lang.String[]) } * with the second parameter <code>fieldNames.split("\\.")</code>. * * @param source The object on which to invoke the first getter * @param fieldNames The field names which should be used for the getter * determination */ @SuppressWarnings("unchecked") public LazyGetterMethod(Object source, String fieldNames) { this.source = source; this.expression = (PropertyPathExpression<Object, Object>) ExpressionUtils .getExpression(source.getClass(), fieldNames); }
public Hibernate5TransactionSynchronizationStrategy(EntityManager em) { try { this.tx = em.getTransaction(); } catch (IllegalStateException e) { throw new IllegalStateException("Could not access entity transaction!", e); } try { Object s = em.unwrap(Class.forName("org.hibernate.Session")); this.synchronizationRegistry = ExpressionUtils.getNullSafeValue(s, "transactionCoordinator.localSynchronizations"); this.registerSynchronization = ReflectionUtils.getMethod(synchronizationRegistry.getClass(), "registerSynchronization", Synchronization.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
@Override public int compare(T object1, T object2) { try { Integer result = compareNullObjects(object1, object2); if (result == null) { // Retrieve field values of the objects Object value1 = ExpressionUtils.getValue(object1, propertyPath); Object value2 = ExpressionUtils.getValue(object2, propertyPath); result = compareNullObjects(value1, value2); if (result == null) { result = collator.compare((value1 instanceof String) ? value1 : value1.toString(), (value2 instanceof String) ? value2 : value2.toString()); } } return result; } catch (Throwable e) { throw new IllegalArgumentException(new StringBuilder( "Could not compare !!! object1: ") .append(object1.getClass().getName()) .append(" / object2: ") .append(object2.getClass().getName()) .append(" / propertyPath: ").append(propertyPath) .toString(), e); } } }
/** * Constructs a LazySetterMethod object for the given source object, field * names as a string separated by '.' (dots) and arguments. Using this * constructor is equal to # * {@link LazySetterMethod#LazySetterMethod(java.lang.Object, java.lang.String[], java.lang.Object[]) } * with the second parameter <code>fieldNames.split("\\.")</code>. * * @param target The object on which to invoke the getter/setter chain * @param fieldNames The field names which should be used for the setter * determination * @param args The arguments used for the setter method */ @SuppressWarnings("unchecked") public LazySetterMethod(Object target, String fieldNames, Object value) { if (target == null) { throw new NullPointerException("target"); } this.target = target; this.value = value; this.expression = (PropertyPathExpression<Object, Object>) ExpressionUtils .getExpression(target.getClass(), fieldNames); }
public Hibernate4TransactionSynchronizationStrategy(EntityManager em) { try { this.tx = em.getTransaction(); } catch (IllegalStateException e) { throw new IllegalStateException("Could not access entity transaction!", e); } try { Object s = em.unwrap(Class.forName("org.hibernate.Session")); this.synchronizationRegistry = ExpressionUtils.getNullSafeValue(s, "transactionCoordinator.synchronizationRegistry"); this.registerSynchronization = ReflectionUtils.getMethod(synchronizationRegistry.getClass(), "registerSynchronization", Synchronization.class); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }
@SuppressWarnings("unchecked") public static <X, Y> Y getNullSafeValue(X target, String propertyPath, Class<Y> valueClass) { return target == null ? null : getExpression( (Class<X>) target.getClass(), propertyPath, valueClass) .getNullSafeValue(target); }
public static <X, Y> Y getValue(Class<X> source, X target, String propertyPath, Class<Y> valueClass) { return getExpression(source, propertyPath, valueClass).getValue(target); }
public static <X, Y> PropertyPathExpressionValueHolder<X, Y> getValueHolder( Class<X> source, X target, String propertyPath, Class<Y> valueClass) { return new PropertyPathExpressionValueHolder<X, Y>(target, getExpression(source, propertyPath, valueClass)); }
public static <X, Y> Y getNullSafeValue(Class<X> source, X target, String propertyPath, Class<Y> valueClass) { return getExpression(source, propertyPath, valueClass) .getNullSafeValue(target); }
@SuppressWarnings("unchecked") public static <X, Y> void setValue(X target, String propertyPath, Y value) { getExpression((Class<X>) target.getClass(), propertyPath).setValue( target, value); }
@SuppressWarnings("unchecked") public static <X, Y> Y getValue(X target, String propertyPath, Class<Y> valueClass) { return getExpression((Class<X>) target.getClass(), propertyPath, valueClass).getValue(target); }
public static <X, Y> void setValue(Class<X> source, X target, String propertyPath, Y value) { getExpression(source, propertyPath).setValue(target, value); }