当前位置: 首页>>代码示例>>Java>>正文


Java DefaultAttribute类代码示例

本文整理汇总了Java中org.netbeans.jpa.modeler.spec.DefaultAttribute的典型用法代码示例。如果您正苦于以下问题:Java DefaultAttribute类的具体用法?Java DefaultAttribute怎么用?Java DefaultAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultAttribute类属于org.netbeans.jpa.modeler.spec包,在下文中一共展示了DefaultAttribute类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isExist

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
/**
 * For EmbeddedId
 * @param keys
 * @param defaultClass
 * @return 
 */
    private static boolean isExist(String[] keys, DefaultClass defaultClass) {
    if (keys.length > 1) {
        Optional<DefaultAttribute> embeddedOptional = defaultClass.getAttributes()
                .getDefaultAttributes()
                .stream()
                .filter(e -> e.getName().equalsIgnoreCase(keys[0]))
                .findAny();
        if (embeddedOptional.isPresent()) {
            return true;// TODO defaultattribute connected class => nested => isExist(Arrays.copyOfRange(keys, 1, keys.length), embeddedOptional.get().getConnectedClass());
        } else {
            return false;
        }
    } else {
        Optional<DefaultAttribute> attrOptional = defaultClass.getAttributes()
                .getDefaultAttributes()
                .stream()
                .filter(e -> e.getName().equalsIgnoreCase(keys[0]))
                .findAny();
        return attrOptional.isPresent();
    }
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:28,代码来源:AttributeValidator.java

示例2: getClassDef

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
public ClassDefSnippet getClassDef() {
    for (DefaultAttribute defaultAttribute : defaultClass.getAttributes()) {
        VariableDefSnippet variableDef = getVariableDef(defaultAttribute.getName());
        variableDef.setType(defaultAttribute.getAttributeType());
    }
    //Class decorations
    ClassHelper classHelper = new ClassHelper(defaultClass.getClazz());
    classHelper.setPackageName(packageName);

    classDef.setVariableDefs(new ArrayList<VariableDefSnippet>(variables.values()));
    classDef.setClassName(classHelper.getFQClassName());
    classDef.setPackageName(classHelper.getPackageName());
    classDef.setDefaultClass(true);

    return classDef;
}
 
开发者ID:foxerfly,项目名称:Netbeans-JPA-Modeler,代码行数:17,代码来源:DefaultClassGenerator.java

示例3: findAllAttribute

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
@Override
public List<Attribute> findAllAttribute(String name, boolean includeParentClassAttibute) {
    List<Attribute> attributes = super.findAllAttribute(name, includeParentClassAttibute);

    for (DefaultAttribute defaultAttribute : getDefaultAttributes()) {
        if (defaultAttribute.getName() != null && defaultAttribute.getName().equals(name)) {
            attributes.add(defaultAttribute);
        }
    }
    return attributes;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:12,代码来源:DefaultAttributes.java

示例4: getDefaultAttributes

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
/**
 * @return the defaultAttributes
 */
public List<DefaultAttribute> getDefaultAttributes() {
    if (this.defaultAttributes == null) {
        this.defaultAttributes = new ArrayList<>();
    }
    return defaultAttributes;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:10,代码来源:DefaultAttributes.java

示例5: getInstance

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
public static DefaultEmbeddedAttributeSpecAccessor getInstance(DefaultAttribute attribute, boolean inherit) {
    DefaultEmbeddedAttributeSpecAccessor accessor = new DefaultEmbeddedAttributeSpecAccessor(attribute);
    accessor.inherit = inherit;
    accessor.setName(attribute.getName());
    accessor.setAttributeType(attribute.getAttributeType());
    return accessor;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:8,代码来源:DefaultEmbeddedAttributeSpecAccessor.java

示例6: getInstance

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
public static DefaultAttributeSpecAccessor getInstance(DefaultAttribute attribute, boolean inherit) {
    DefaultAttributeSpecAccessor accessor = new DefaultAttributeSpecAccessor(attribute);
    accessor.inherit = inherit;
    accessor.setName(attribute.getName());
    accessor.setAttributeType(attribute.getAttributeType());
    accessor.setColumn(attribute.getColumn().getAccessor());
    return accessor;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:9,代码来源:DefaultAttributeSpecAccessor.java

示例7: setDefaultAttributes

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
/**
 * @param attributes the defaultAttributes to set
 */
public void setDefaultAttributes(List<DefaultAttribute> attributes) {
    this.defaultAttributes = attributes;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:7,代码来源:DefaultAttributes.java

示例8: addDefaultAttribute

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
public void addDefaultAttribute(DefaultAttribute attribute) {
    getDefaultAttributes().add(attribute);
    attribute.setAttributes(this);
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:5,代码来源:DefaultAttributes.java

示例9: removeDefaultAttribute

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
public void removeDefaultAttribute(DefaultAttribute attribute) {
    getDefaultAttributes().remove(attribute);
    attribute.setAttributes(null);
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:5,代码来源:DefaultAttributes.java

示例10: DefaultEmbeddedAttributeSpecAccessor

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
private DefaultEmbeddedAttributeSpecAccessor(DefaultAttribute attribute) {
    this.attribute = attribute;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:4,代码来源:DefaultEmbeddedAttributeSpecAccessor.java

示例11: DefaultAttributeSpecAccessor

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
private DefaultAttributeSpecAccessor(DefaultAttribute attribute) {
    this.attribute = attribute;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:4,代码来源:DefaultAttributeSpecAccessor.java

示例12: generate

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
/**
 * Generates the repository for the given entity class.
 *
 * @return the generated files.
 */
private FileObject generate(final Entity entity, boolean overrideExisting) throws IOException {
    FileObject targetFolder = SourceGroupSupport.getFolderForPackage(appConfigData.getTargetSourceGroup(), 
            entity.getAbsolutePackage(appConfigData.getTargetPackage() + '.' + repositoryData.getPackage()), 
            true);
    String entityFQN = entity.getFQN();
    final String entitySimpleName = entity.getClazz();
    String abstractFileName = repositoryData.getPrefixName() + REPOSITORY_ABSTRACT + repositoryData.getSuffixName();
    String repositoryName = repositoryData.getPrefixName() + entitySimpleName + repositoryData.getSuffixName();
    // create the repository
    FileObject existingFO = targetFolder.getFileObject(repositoryName, JAVA_EXT);
    if (existingFO != null) {
        if (overrideExisting) {
            existingFO.delete();
        } else {
            throw new IOException("File already exists exception: " + existingFO.getPath());
        }
    }

    String entityClass = firstUpper(entitySimpleName);
    String entityInstance = firstLower(entitySimpleName);

    Map<String, Object> param = new HashMap<>();
    param.put("EntityClass", entityClass);
    param.put("EntityClassPlural", pluralize(entityClass));
    param.put("EntityClass_FQN", entityFQN);
    param.put("entityInstance", entityInstance);
    param.put("entityInstancePlural", pluralize(entityInstance));

    param.put("AbstractRepository", abstractFileName);
    if (!entity.getAbsolutePackage(repositoryData.getPackage()).equals(repositoryData.getPackage())) { //if both EntityRepository and AbstractRepository are not in same package
        param.put("AbstractRepository_FQN", '.' + repositoryData.getPackage() + "." + abstractFileName);
    } else {
        param.put("AbstractRepository_FQN", EMPTY);
    }
    param.put("EntityRepository", repositoryName);
    param.put("PU", entityMapping.getPersistenceUnitName());
    param.put("package", entity.getAbsolutePackage(appConfigData.getTargetPackage() + '.' + repositoryData.getPackage()));
    param.put("cdi", repositoryData.isCDI());
    param.put("named", repositoryData.isNamed());
    param.put("appPackage", appConfigData.getTargetPackage());

    Attribute idAttribute = entity.getAttributes().getIdField();
    if (idAttribute != null) {
        if (idAttribute instanceof Id) {
            String dataType_FQN = idAttribute.getDataTypeLabel();
            param.put("EntityPKClass_FQN", EMPTY);
            if (isPrimitive(dataType_FQN)) {
                param.put("EntityPKClass", getWrapperType(dataType_FQN));
            } else {
                String dataType = JavaIdentifiers.unqualify(dataType_FQN);
                param.put("EntityPKClass", dataType);
                if (dataType.length() != dataType_FQN.length()) {
                    param.put("EntityPKClass_FQN", dataType_FQN);
                }
            }
        } else if (idAttribute instanceof EmbeddedId || idAttribute instanceof DefaultAttribute) {
            param.put("EntityPKClass", idAttribute.getDataTypeLabel());
            param.put("EntityPKClass_FQN", entity.getRootPackage() + '.' + idAttribute.getDataTypeLabel());
        }
    }

    existingFO = org.netbeans.jcode.core.util.FileUtil.expandTemplate(TEMPLATE + "repository/EntityRepository.java.ftl", targetFolder, repositoryName + '.' + JAVA_EXT, param);

    return existingFO;
}
 
开发者ID:jeddict,项目名称:jCode,代码行数:71,代码来源:RepositoryGenerator.java

示例13: getSnippet

import org.netbeans.jpa.modeler.spec.DefaultAttribute; //导入依赖的package包/类
@Override
public String getSnippet() throws InvalidDataException {
    StringBuilder builder = new StringBuilder();
    int startNumber = generatePrimeNumber(2, 10);
    int multiplyNumber = generatePrimeNumber(10, 100);

    if(!classMembers.getAttributes().isEmpty()){
        builder.append(String.format("int hash = %s;",startNumber)).append(NEW_LINE);
    }
    
    if (StringUtils.isNotBlank(classMembers.getPreCode())) {
        builder.append(classMembers.getPreCode()).append(NEW_LINE);
    }
    
    for (int i = 0; i < classMembers.getAttributes().size(); i++) {
        Attribute attribute = classMembers.getAttributes().get(i);
        if(attribute instanceof DefaultAttribute) {
            attribute = ((DefaultAttribute)attribute).getConnectedAttribute();
        }
        
        String expression;
        boolean optionalType = attribute.isOptionalReturnType();
        if(attribute instanceof BaseAttribute && !(attribute instanceof CompositionAttribute)){
            expression = getHashcodeExpression(((BaseAttribute)attribute).getAttributeType(), attribute.getName(), optionalType);
        } else {
            expression = getHashcodeExpression(attribute.getName(), optionalType);
        }
        builder.append("        ")
               .append(String.format("hash = %s * hash + %s;", multiplyNumber, expression)).append(NEW_LINE);
    }
    
    if (StringUtils.isNotBlank(classMembers.getPostCode())) {
        builder.append(classMembers.getPostCode()).append(NEW_LINE);
    }
    
    if(!classMembers.getAttributes().isEmpty()){
        builder.append("        ")
               .append("return hash;");
    }
    return builder.toString();
}
 
开发者ID:jeddict,项目名称:jeddict,代码行数:42,代码来源:HashcodeMethodSnippet.java


注:本文中的org.netbeans.jpa.modeler.spec.DefaultAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。