/** * Returns a new {@link TextValue} representing a string text. * * @param text the text * @return the text value */ static TextValue ofText(String text) { return new TextValueImpl(text); }
/** * Returns a new {@link BooleanValue} with the specified value. * * @param val the boolean * @return the boolean value */ static BooleanValue ofBoolean(Boolean val) { return new BooleanValueImpl(val); }
@Override public BooleanValueImpl copy() { return new BooleanValueImpl(getValue()); } }
@Override public NumberValueImpl copy() { return new NumberValueImpl(getValue()); } }
@Override public ReferenceValueImpl copy() { return new ReferenceValueImpl(getValue()); } }
@Override public TextValueImpl copy() { return new TextValueImpl(getValue()); } }
@Override public ArrayValueImpl copy() { return new ArrayValueImpl(Copier.copy(getValue(), s -> s.copy())); } }
@Override public int hashCode() { int result = args != null ? args.hashCode() : 0; result = 31 * result + typeParams.hashCode(); result = 31 * result + getFields().hashCode(); result = 31 * result + getMethods().hashCode(); result = 31 * result + getInitializers().hashCode(); result = 31 * result + innerClasses.hashCode(); return result; } }
/** * Returns a new {@link ArrayValue} with the specified values set. * * @param values the values to initialize the array with * @return an {@code ArrayValue} */ static ArrayValue ofArray(List<Value<?>> values) { return new ArrayValueImpl(values); }
/** * Returns a new {@link EnumValue} with the specified constant selected. * * @param type the enum type * @param constant the selected constant * @return the boolean value */ static EnumValue ofEnum(Type type, String constant) { return new EnumValueImpl(type, constant); }
/** * Returns a new {@link AnonymousValue} representing the anonymous * implementation of a class or interface as the value of a field. * * @param implementedType the class or interface to implement * @return the anonymous value */ static AnonymousValue ofAnonymous(Type implementedType) { return new AnonymousValueImpl() .setValue(implementedType); }
/** * Returns a new {@link ReferenceValue} representing a reference to an * object. * * @param reference the code to show * @return the reference value */ static ReferenceValue ofReference(String reference) { return new ReferenceValueImpl(reference); }
/** * Returns a new {@code NullValue} representing {@code null}. * * @return a {@code NullValue} */ static NullValue ofNull() { return new NullValueImpl(); }
/** * Returns a new {@link NumberValue}. * * @param num the represented number * @return the created number value */ static NumberValue ofNumber(Number num) { return new NumberValueImpl(num); }
/** * Returns a new {@link InvocationValue} representing a call to the * specified local method with the specified arguments. * * @param method the local method to invoke * @param args the arguments to pass to it * @return the created invocation */ static InvocationValue ofInvocation(String method, Value<?>... args) { final InvocationValue result = new InvocationValueImpl() .setValue(method); Stream.of(args).forEachOrdered(result::add); return result; }
@Override public Value<String> copy() { return new InvocationValueImpl(this); }
@Override public AnonymousValue copy() { return new AnonymousValueImpl(this); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof AnonymousValue)) return false; AnonymousValue that = (AnonymousValue) o; if (args != null ? !args.equals(that.getValue()) : that.getValue() != null) return false; if (!typeParams.equals(that.getTypeParameters())) return false; if (!getFields().equals(that.getFields())) return false; if (!getMethods().equals(that.getMethods())) return false; if (!getInitializers().equals(that.getInitializers())) return false; return innerClasses.equals(that.getClasses()); }
/** * Returns a new {@link ArrayValue} with no values set. * * @return an {@code ArrayValue} */ static ArrayValue ofArray() { return new ArrayValueImpl(); }
@Override public EnumValueImpl copy() { return new EnumValueImpl(this); }