/** * Creates a 'string' value with the specified content. * * @param text the inner text * @return a value representing that string */ public static Value<String> string(String text) { return Value.ofText(requireNonNull(text)); } }
AnnotationUsageBase(AnnotationUsage prototype) { type = prototype.getType(); value = prototype.getValue().map(Copier::copy).orElse(null); values = Copier.copy(prototype.getValues(), e -> new AbstractMap.SimpleEntry<>( e.getKey(), e.getValue().copy() ) ); }
/** * Sets the value of this model to a new {@link BooleanValue} holding the * specified {@code Boolean}. * * @param val the new value * @return a reference to this */ default T set(final Boolean val) { return set(ofBoolean(val)); }
.add(Value.ofText(constant)) .add(Value.ofNumber(ordinal)); ofReference("Identifier." + fieldName), ofReference( usesOptional(col) ? "o -> " + OptionalUtil.class.getSimpleName() + ".unwrap(o.get" + translator.getSupport().typeName(col) + "())" : translator.getSupport().entityName() + "::get" + translator.getSupport().typeName(col) ), ofReference( translator.getSupport().entityName() + "::set" + translator.getSupport().typeName(col) ), ofAnonymous(TypeMapper.class) .add(wrapIfPrimitive(dbType)) .add(enumType) params.add(ofReference( holder.getForeignEmt().getSupport().entityName() + "." + translator.getSupport().namer().javaStaticFieldName( params.add(Value.ofReference(enumShortName + "::" + TO_DATABASE_METHOD)); params.add(Value.ofReference(enumShortName + "::" + FROM_DATABASE_METHOD)); params.add(Value.ofReference(enumShortName + ".class")); field.set(ofInvocation( existing.map(InvocationValue::getType).orElseGet( () -> fk.isPresent()
identifierEnum.add(EnumConstant.of(constant).add(Value.ofText(col.getId()))); fieldParams.add(Value.ofReference("Identifier." + constant)); fieldParams.add(Value.ofReference( "o -> OptionalUtil.unwrap(o." + GETTER_METHOD_PREFIX + fieldParams.add(Value.ofReference( shortEntityName + "::get" + getSupport().typeName(col))); fieldParams.add(Value.ofReference( shortEntityName + "::" + SETTER_METHOD_PREFIX + getSupport().typeName(col))); fieldParams.add(Value.ofReference( fuSupport.entityName() + "." + fuSupport.namer().javaStaticFieldName( fieldParams.add(Value.ofReference("TypeMapper.primitive()")); } else { file.add(Import.of(SimpleType.create(typeMapper))); fieldParams.add(Value.ofReference("new " + shortName(typeMapper) + "()")); fieldParams.add(Value.ofReference("TypeMapper.identity()")); file.add(Import.of(TypeMapper.class)); fieldParams.add(Value.ofBoolean(DocumentDbUtil.isUnique(col)));
"IDENTIFIER", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType()) ).set(Value.ofInvocation(TableIdentifier.class, "of", Stream.<HasAlias>of( table.getParentOrThrow().getParentOrThrow(), com.speedment.runtime.field.Field.class, getSupport().entityType()) )).set(Value.ofReference("unmodifiableList(asList(" + nl() + indent( table.columns() .sorted(comparing(Column::getOrdinalPosition))
/** * Sets the value of this model to a new {@link NumberValue} holding the * specified {@code Number}. * * @param val the new value * @return a reference to this */ default T set(final Number val) { return set(ofNumber(val)); }
private AnnotationUsage withExecuteBefore(File file) { file.add(Import.of(State.class).static_().setStaticMember("RESOLVED")); return AnnotationUsage.of(ExecuteBefore.class).set(Value.ofReference("RESOLVED")); }
identifierEnum.add(EnumConstant.of(constant).add(Value.ofText(col.getId()))); fieldParams.add(Value.ofReference("Identifier." + constant)); fieldParams.add(Value.ofReference( "o -> OptionalUtil.unwrap(o." + GETTER_METHOD_PREFIX + fieldParams.add(Value.ofReference( shortEntityName + "::get" + getSupport().typeName(col))); fieldParams.add(Value.ofReference( shortEntityName + "::" + SETTER_METHOD_PREFIX + getSupport().typeName(col))); fieldParams.add(Value.ofReference( fuSupport.entityName() + "." + fuSupport.namer().javaStaticFieldName( fieldParams.add(Value.ofReference("TypeMapper.primitive()")); } else { file.add(Import.of(SimpleType.create(typeMapper))); fieldParams.add(Value.ofReference("new " + shortName(typeMapper) + "()")); fieldParams.add(Value.ofReference("TypeMapper.identity()")); file.add(Import.of(TypeMapper.class)); fieldParams.add(Value.ofBoolean(DocumentDbUtil.isUnique(col)));
"IDENTIFIER", SimpleParameterizedType.create(TableIdentifier.class, getSupport().entityType()) ).set(Value.ofInvocation(TableIdentifier.class, "of", Stream.<HasAlias>of( table.getParentOrThrow().getParentOrThrow(), com.speedment.runtime.field.Field.class, getSupport().entityType()) )).set(Value.ofReference("unmodifiableList(asList(" + nl() + indent( table.columns() .sorted(comparing(Column::getOrdinalPosition))
/** * Creates a public final static {@link Field} with the specified value and * adds it to this model. * * @param name the name of the field * @param type the type of the field * @param value the value of the field * @return a reference to this * * @since 2.5 */ default T constant(final String name, Type type, Number value) { return constant(name, type, ofNumber(value)); }
initializer.add("return " + STRING_BUILDER_NAME + ".toString();"); metadataField.set(Value.ofReference("init()")); getMetadata.add("return Optional.of(METADATA);");
/** * Sets the value of this model to a new {@link TextValue} holding the * specified {@code String}. * * @param val the new value * @return a reference to this */ default T set(final String val) { return set(ofText(val)); }
@Override public ArrayValueImpl copy() { return new ArrayValueImpl(Copier.copy(getValue(), s -> s.copy())); } }
/** * Use the specified key-value pair when referencing the annotation. If you * only want to show a single value without any key, consider using the * {@link #set(Value)} method. * <p> * This method works like {@link #put(String, Value)} except that the type * of the value is automatically determined as a {@link NumberValue}. * * @param key the key * @param numberValue the value * @return a reference to this model * * @since 2.5 */ default AnnotationUsage put(String key, Number numberValue) { return put(key, Value.ofNumber(numberValue)); }
/** * Creates a public final static {@link Field} with the specified value and * adds it to this model. * * @param name the name of the field * @param type the type of the field * @param value the value of the field * @return a reference to this * * @since 2.5 */ default T constant(final String name, Type type, Boolean value) { return constant(name, type, ofBoolean(value)); }
private AnnotationUsage withExecuteBefore(File file) { file.add(Import.of(State.class).static_().setStaticMember("RESOLVED")); return AnnotationUsage.of(ExecuteBefore.class).set(Value.ofReference("RESOLVED")); }
/** * Creates a public final static {@link Field} with the specified value and * adds it to this model. * * @param name the name of the field * @param type the type of the field * @param value the value of the field * @return a reference to this * * @since 2.5 */ default T constant(final String name, Type type, String value) { return constant(name, type, ofText(value)); }
/** * Copy constructor. * * @param prototype the prototype */ protected EnumConstantImpl(EnumConstant prototype) { name = requireNonNull(prototype).getName(); javadoc = prototype.getJavadoc().orElse(null); imports = Copier.copy(prototype.getImports()); classes = Copier.copy(prototype.getClasses(), c -> c.copy()); initializers = Copier.copy(prototype.getInitializers(), c -> c.copy()); methods = Copier.copy(prototype.getMethods(), c -> c.copy()); fields = Copier.copy(prototype.getFields(), c -> c.copy()); values = Copier.copy(prototype.getValues(), c -> c.copy()); annotations = Copier.copy(prototype.getAnnotations(), c -> c.copy()); }
/** * Sets the value of this model to a new {@link NumberValue} holding the * specified {@code Number}. * * @param val the new value * @return a reference to this */ default T set(final Number val) { return set(ofNumber(val)); }