當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。