Ejemplo n.º 1
0
  @Override
  public boolean supports(TherianContext context, Add<?, ? extends Collection<?>> add) {
    // cannot add to immutable types
    if (context.eval(ImmutableCheck.of(add.getTargetPosition())).booleanValue()) {
      return false;
    }
    if (!TypeUtils.isAssignable(add.getTargetPosition().getType(), Collection.class)) {
      return false;
    }
    final Type targetElementType =
        TypeUtils.unrollVariables(
            TypeUtils.getTypeArguments(add.getTargetPosition().getType(), Collection.class),
            Collection.class.getTypeParameters()[0]);

    if (targetElementType == null) {
      // raw collection
      return true;
    }
    return TypeUtils.isAssignable(add.getSourcePosition().getType(), targetElementType);
  }
Ejemplo n.º 2
0
 public boolean supports(Copy<?, ?> operation) {
   return operation.getTargetPosition() instanceof Position.Writable
       && TherianContext.getRequiredInstance()
           .eval(ImmutableCheck.of(operation.getTargetPosition()))
           .booleanValue();
 }
Ejemplo n.º 3
0
 public void perform(Copy<?, ?> operation) {
   final Convert<?, ?> convert =
       Convert.to(
           (Position.Writable<?>) operation.getTargetPosition(), operation.getSourcePosition());
   TherianContext.getRequiredInstance().forwardTo(convert);
 }