org.jboss.forge.roaster.model.source.FieldSource Java Examples

The following examples show how to use org.jboss.forge.roaster.model.source.FieldSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityIndexDataProvider.java    From Entitas-Java with MIT License 6 votes vote down vote up
private ComponentData createEntityIndexData(ComponentData data, List<FieldSource<JavaClassSource>> infos) {

        FieldSource<JavaClassSource> info = infos.stream()
                .filter(i -> i.hasAnnotation(EntityIndex.class))
                .collect(singletonCollector());

        setEntityIndexType(data, info.getAnnotation(EntityIndex.class).getName());
        isCustom(data, false);
        setEntityIndexName(data, data.getSource().getCanonicalName());
        setKeyType(data, info.getType().getName());
        setComponentType(data, data.getSource().getCanonicalName());
        setMemberName(data, info.getName());
        _contextsComponentDataProvider.provide(data);
        setContextNames(data, _contextsComponentDataProvider.getContextNames(data));

        return data;
    }
 
Example #2
Source File: ComponentEntityGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
public String memberAssignments(List<FieldSource<JavaClassSource>> memberInfos) {
    String format = "component.%1$s = %2$s;";
    return memberInfos.stream().map(
            info -> {
                String newArg = info.getName();
                return String.format(format, info.getName(), newArg);
            }
    ).collect(Collectors.joining("\n"));

}
 
Example #3
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 5 votes vote down vote up
public Field<JavaClassSource> createTemporalField(JavaClassSource entityClass, String fieldName, TemporalType type)
         throws FileNotFoundException
{
   FieldSource<JavaClassSource> field = fieldOperations.addFieldTo(entityClass, Date.class.getCanonicalName(),
            fieldName,
            TemporalType.class.getCanonicalName());
   field.addAnnotation(Temporal.class).setEnumValue(type);
   return field;
}
 
Example #4
Source File: MemberDataProvider.java    From Entitas-Java with MIT License 5 votes vote down vote up
@Override
public void provide(ComponentData data) {
    List<FieldSource<JavaClassSource>> fields = data.getSource().getFields();
    if(fields != null && fields.size() > 0) {
        setMemberData(data, data.getSource().getFields());
        setFlagComponent(data,false);
    } else {
        setMemberData(data, new ArrayList<FieldSource<JavaClassSource>>());
        setFlagComponent(data,true);
    }

}
 
Example #5
Source File: ComponentDataProvider.java    From Entitas-Java with MIT License 5 votes vote down vote up
List<ComponentData> provideDataForNonComponent(ComponentData data) {
    _contextsComponentDataProvider.provide(data);
    return getComponentNames(data.getSource()).stream()
            .map(componentName -> {
                ComponentTypeDataProvider.setFullTypeName(data, componentName);
                MemberDataProvider.setMemberData(data, new ArrayList<FieldSource<JavaClassSource>>() {{
                    add(new FieldImpl<JavaClassSource>(data.getSource()));
                }});
                return data;
            }).collect(Collectors.toList());

}
 
Example #6
Source File: CamelJavaParserHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static FieldSource<JavaClassSource> getField(JavaClassSource clazz, Block block, SimpleName ref) {
    String fieldName = ref.getIdentifier();
    if (fieldName != null) {
        // find field in class
        FieldSource field = clazz != null ? clazz.getField(fieldName) : null;
        if (field == null) {
            field = findFieldInBlock(clazz, block, fieldName);
        }
        return field;
    }
    return null;
}
 
Example #7
Source File: CamelJavaParserHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
private static boolean isNumericOperator(JavaClassSource clazz, Block block, Expression expression) {
    if (expression instanceof NumberLiteral) {
        return true;
    } else if (expression instanceof SimpleName) {
        FieldSource field = getField(clazz, block, (SimpleName) expression);
        if (field != null) {
            return field.getType().isType("int") || field.getType().isType("long")
                    || field.getType().isType("Integer") || field.getType().isType("Long");
        }
    }
    return false;
}
 
Example #8
Source File: ContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}
 
Example #9
Source File: ContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}
 
Example #10
Source File: CreateTestClassCommand.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
private void addArquillianResourceEnricher(JavaClassSource test) {
    if (asClient.hasValue()) {
        test.addImport("org.jboss.arquillian.test.api.ArquillianResource");
        final FieldSource<JavaClassSource> urlField = test.addField();
        urlField
                .setName("url")
                .setType(URL.class)
                .setPrivate();

        urlField.addAnnotation("ArquillianResource");

    }
}
 
Example #11
Source File: ComponentContextGenerator.java    From Entitas-Java with MIT License 5 votes vote down vote up
private void addImports(List<FieldSource<JavaClassSource>> memberInfos, JavaClassSource source) {
    for (FieldSource<JavaClassSource> info : memberInfos) {
        if (info.getOrigin().getImport(info.getType().toString()) != null) {
            if (source.getImport(info.getType().toString()) == null) {
                source.addImport(info.getType());
            }
        }
    }
}
 
Example #12
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createStringField(JavaClassSource entityClass, String fieldName)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, String.class.getSimpleName(), fieldName);
}
 
Example #13
Source File: MemberDataProvider.java    From Entitas-Java with MIT License 4 votes vote down vote up
public static void setMemberData(ComponentData data, List<FieldSource<JavaClassSource>> memberInfos) {
    data.put(COMPONENT_MEMBER_INFOS, memberInfos);
}
 
Example #14
Source File: ContextGenerator.java    From Entitas-Java with MIT License 4 votes vote down vote up
public String memberNames(List<FieldSource<JavaClassSource>> memberInfos) {
    return memberInfos.stream()
            .map(info -> info.getName())
            .collect(Collectors.joining(", "));
}
 
Example #15
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createNumericField(JavaClassSource entityClass, String fieldName,
         Class<? extends Number> type)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, type.getCanonicalName(), fieldName);
}
 
Example #16
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createBooleanField(JavaClassSource entityClass, String fieldName)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, boolean.class.getSimpleName(), fieldName);
}
 
Example #17
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createBooleanWrapperField(JavaClassSource entityClass, String fieldName)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, Boolean.class.getSimpleName(), fieldName);
}
 
Example #18
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createIntField(JavaClassSource entityClass, String fieldName)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, int.class.getName(), fieldName);
}
 
Example #19
Source File: ProjectHelper.java    From angularjs-addon with Eclipse Public License 1.0 4 votes vote down vote up
public FieldSource<JavaClassSource> createLongField(JavaClassSource entityClass, String fieldName)
         throws FileNotFoundException
{
   return fieldOperations.addFieldTo(entityClass, int.class.getName(), fieldName);
}
 
Example #20
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setType(Class clazz) {
    return null;
}
 
Example #21
Source File: MemberDataProvider.java    From Entitas-Java with MIT License 4 votes vote down vote up
public static List<FieldSource<JavaClassSource>> getMemberData(ComponentData data) {
    return (List<FieldSource<JavaClassSource>>) data.get(COMPONENT_MEMBER_INFOS);
}
 
Example #22
Source File: ComponentEntityGenerator.java    From Entitas-Java with MIT License 4 votes vote down vote up
public String memberNames(List<FieldSource<JavaClassSource>> memberInfos) {
    return memberInfos.stream()
            .map(info -> info.getName())
            .collect(Collectors.joining(", "));
}
 
Example #23
Source File: ComponentEntityGenerator.java    From Entitas-Java with MIT License 4 votes vote down vote up
public String memberNamesWithType(List<FieldSource<JavaClassSource>> memberInfos) {
    return memberInfos.stream()
            .map(info -> info.getType() + " " + info.getName())
            .collect(Collectors.joining(", "));

}
 
Example #24
Source File: ComponentContextGenerator.java    From Entitas-Java with MIT License 4 votes vote down vote up
public String memberNames(List<FieldSource<JavaClassSource>> memberInfos) {
    return memberInfos.stream()
            .map(data -> data.getName())
            .collect(Collectors.joining(", "));
}
 
Example #25
Source File: ContextGenerator.java    From Entitas-Java with MIT License 4 votes vote down vote up
public String memberNames(List<FieldSource<JavaClassSource>> memberInfos) {
    return memberInfos.stream()
            .map(info -> info.getName())
            .collect(Collectors.joining(", "));
}
 
Example #26
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setType(JavaType entity) {
    return null;
}
 
Example #27
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setVolatile(boolean value) {
    return null;
}
 
Example #28
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setTransient(boolean value) {
    return null;
}
 
Example #29
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setStringInitializer(String value) {
    return null;
}
 
Example #30
Source File: StatementFieldSource.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Override
public FieldSource setLiteralInitializer(String value) {
    return null;
}