@Override @SuppressFBWarnings(value = "EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS", justification = "Type check is performed by erasure implementation") public boolean equals(Object other) { if (this == other) { return true; } else if (getSort().isNonGeneric()) { return asErasure().equals(other); } if (!(other instanceof Generic)) { return false; } Generic typeDescription = (Generic) other; return typeDescription.getSort().isGenericArray() && getComponentType().equals(typeDescription.getComponentType()); }
/** * {@inheritDoc} */ public AnnotationAppender onNonGenericType(TypeDescription.Generic typeDescription) { StringBuilder typePath = new StringBuilder(this.typePath); for (int index = 0; index < typeDescription.asErasure().getInnerClassCount(); index++) { typePath = typePath.append(INNER_CLASS_PATH); } AnnotationAppender annotationAppender = apply(typeDescription, typePath.toString()); if (typeDescription.isArray()) { annotationAppender = typeDescription.getComponentType().accept(new ForTypeAnnotations(annotationAppender, annotationValueFilter, typeReference, this.typePath + COMPONENT_TYPE_PATH)); // Impossible to be inner class } return annotationAppender; }
/** * {@inheritDoc} */ public StackManipulation toStackManipulation(ParameterDescription target, Assigner assigner, Assigner.Typing typing) { TypeDescription.Generic componentType; if (target.getType().represents(Object.class)) { componentType = TypeDescription.Generic.OBJECT; } else if (target.getType().isArray()) { componentType = target.getType().getComponentType(); } else { throw new IllegalStateException("Cannot set method parameter array for non-array type: " + target); } List<StackManipulation> stackManipulations = new ArrayList<StackManipulation>(parameters.size()); for (ParameterDescription parameter : parameters) { StackManipulation stackManipulation = new StackManipulation.Compound( MethodVariableAccess.load(parameter), assigner.assign(parameter.getType(), componentType, typing) ); if (stackManipulation.isValid()) { stackManipulations.add(stackManipulation); } else { throw new IllegalStateException("Cannot assign " + parameter + " to " + componentType); } } return new StackManipulation.Compound(ArrayFactory.forType(componentType).withValues(stackManipulations)); }
/** * Append an array type signature * * @param type Array type to append * @param nullable Nullness of type * @param output Output to append to * @param <A> Type of output * @return Supplied output to append to */ public <A extends Appendable> A appendArrayTypeSignature(Generic type, Nullness nullable, A output) { try { output.append('[').append(nullable.getMarker()); appendJavaTypeSignature(Validate.notNull(type.getComponentType()), Nullness.UNDEFINED, output); return output; } catch (Exception e) { throw new RuntimeException(String.format("Could not write array type %s", type)); } }
componentType = TypeDescription.Generic.OBJECT; } else if (target.getType().isArray()) { componentType = target.getType().getComponentType(); } else { throw new IllegalStateException("Expected an array type for all argument annotation on " + source);
/** * {@inheritDoc} */ public OffsetMapping make(ParameterDescription.InDefinedShape target, AnnotationDescription.Loadable<AllArguments> annotation, AdviceType adviceType) { if (!target.getType().represents(Object.class) && !target.getType().isArray()) { throw new IllegalStateException("Cannot use AllArguments annotation on a non-array type"); } else if (adviceType.isDelegation() && !annotation.loadSilent().readOnly()) { throw new IllegalStateException("Cannot define writable field access for " + target); } else { return new ForAllArguments(target.getType().represents(Object.class) ? TypeDescription.Generic.OBJECT : target.getType().getComponentType(), annotation.loadSilent()); } } }
/** * {@inheritDoc} */ public SignatureVisitor onNonGenericType(Generic typeDescription) { if (typeDescription.isArray()) { typeDescription.getComponentType().accept(new ForSignatureVisitor(signatureVisitor.visitArrayType())); } else if (typeDescription.isPrimitive()) { signatureVisitor.visitBaseType(typeDescription.asErasure().getDescriptor().charAt(ONLY_CHARACTER)); } else { signatureVisitor.visitClassType(typeDescription.asErasure().getInternalName()); signatureVisitor.visitEnd(); } return signatureVisitor; }
/** * {@inheritDoc} */ public StackManipulation toStackManipulation(ParameterDescription target, Assigner assigner, Assigner.Typing typing) { StackManipulation stackManipulation = new StackManipulation.Compound( MethodVariableAccess.load(parameterDescription), IntegerConstant.forValue(index), ArrayAccess.of(parameterDescription.getType().getComponentType()).load(), assigner.assign(parameterDescription.getType().getComponentType(), target.getType(), typing) ); if (!stackManipulation.isValid()) { throw new IllegalStateException("Cannot assign " + parameterDescription.getType().getComponentType() + " to " + target); } return stackManipulation; }
/** * {@inheritDoc} */ public Generic onNonGenericType(Generic typeDescription) { return typeDescription.isArray() ? new OfGenericArray.Latent(typeDescription.getComponentType().accept(this), typeDescription) : onSimpleType(typeDescription); }
/** * {@inheritDoc} */ public Generic onGenericArray(Generic genericArray) { return new OfGenericArray.Latent(genericArray.getComponentType().accept(this), genericArray); }
/** * {@inheritDoc} */ public Boolean onNonGenericType(Generic typeDescription) { return typeDescription.isArray() && genericArray.getComponentType().accept(Assigner.INSTANCE).isAssignableFrom(typeDescription.getComponentType()); } }
/** * {@inheritDoc} */ public Generic onGenericArray(Generic genericArray) { return new OfGenericArray.Latent(genericArray.getComponentType().accept(this), Empty.INSTANCE); }
/** * {@inheritDoc} */ public AnnotationAppender onGenericArray(TypeDescription.Generic genericArray) { return genericArray.getComponentType().accept(new ForTypeAnnotations(apply(genericArray, typePath), annotationValueFilter, typeReference, typePath + COMPONENT_TYPE_PATH)); }
/** * {@inheritDoc} */ public Generic getComponentType() { return resolve().getComponentType(); }
/** * {@inheritDoc} */ public Boolean onGenericArray(Generic genericArray) { return this.genericArray.getComponentType().accept(Assigner.INSTANCE).isAssignableFrom(genericArray.getComponentType()); }
/** * {@inheritDoc} */ public Boolean onGenericArray(Generic genericArray) { return isValid(genericArray) && genericArray.getComponentType().accept(this); }
/** * {@inheritDoc} */ public Boolean onNonGenericType(Generic typeDescription) { return isValid(typeDescription) && (!typeDescription.isArray() || typeDescription.getComponentType().accept(this)); }
/** * {@inheritDoc} */ public SignatureVisitor onGenericArray(Generic genericArray) { genericArray.getComponentType().accept(new ForSignatureVisitor(signatureVisitor.visitArrayType())); return signatureVisitor; }
/** * {@inheritDoc} */ public Boolean onGenericArray(Generic genericArray) { return typeDescription.isArray() ? genericArray.getComponentType().accept(new ForNonGenericType(typeDescription.getComponentType())) : typeDescription.represents(Object.class) || TypeDescription.ARRAY_INTERFACES.contains(typeDescription.asGenericType()); }
/** * {@inheritDoc} */ public Generic onNonGenericType(Generic typeDescription) { return typeDescription.isArray() ? new OfGenericArray.Latent(onNonGenericType(typeDescription.getComponentType()), Empty.INSTANCE) : new OfNonGenericType.Latent(typeDescription.asErasure(), Empty.INSTANCE); }