Java 类org.springframework.boot.configurationprocessor.metadata.ItemDeprecation 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessor.java   
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
    AnnotationMirror annotation = getAnnotation(getter,
            deprecatedConfigurationPropertyAnnotation());
    String reason = null;
    String replacement = null;
    if (annotation != null) {
        Map<String, Object> elementValues = getAnnotationElementValues(annotation);
        reason = (String) elementValues.get("reason");
        replacement = (String) elementValues.get("replacement");
    }
    return new ItemDeprecation(("".equals(reason) ? null : reason),
            ("".equals(replacement) ? null : replacement));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessor.java   
private void processSimpleLombokTypes(String prefix, TypeElement element,
        TypeElementMembers members, Map<String, Object> fieldValues) {
    for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
        String name = entry.getKey();
        VariableElement field = entry.getValue();
        if (!isLombokField(field, element)) {
            continue;
        }
        TypeMirror returnType = field.asType();
        Element returnTypeElement = this.processingEnv.getTypeUtils()
                .asElement(returnType);
        boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
        boolean isNested = isNested(returnTypeElement, field, element);
        boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
        boolean hasSetter = hasLombokSetter(field, element);
        if (!isExcluded && !isNested && (hasSetter || isCollection)) {
            String dataType = this.typeUtils.getType(returnType);
            String sourceType = this.typeUtils.getType(element);
            String description = this.typeUtils.getJavaDoc(field);
            Object defaultValue = fieldValues.get(name);
            boolean deprecated = isDeprecated(field) || isDeprecated(element);
            this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
                    dataType, sourceType, null, description, defaultValue,
                    (deprecated ? new ItemDeprecation() : null)));
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
public MetadataItemCondition(ItemType itemType, String name, String type,
        Class<?> sourceType, String description, Object defaultValue,
        ItemDeprecation deprecation) {
    this.itemType = itemType;
    this.name = name;
    this.type = type;
    this.sourceType = sourceType;
    this.description = description;
    this.defaultValue = defaultValue;
    this.deprecation = deprecation;
    describedAs(createDescription());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecation() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata)
            .has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>")
                    .fromSource(SimpleProperties.class)
                    .withDeprecation("Don't use this.", "simple.complex-comparator"));
    assertThat(metadata.getItems()).hasSize(4);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecationOverride() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "single.name"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
    assertThat(metadata).has(
            Metadata.withProperty("singledeprecated.name", String.class.getName())
                    .fromSource(DeprecatedSingleProperty.class)
                    .withDeprecation("Don't use this.", "single.name"));
    assertThat(metadata.getItems()).hasSize(3);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfAdditionalDeprecation() throws Exception {
    writePropertyDeprecation(ItemMetadata.newProperty("simple", "wrongName",
            "java.lang.String", null, null, null, null,
            new ItemDeprecation("Lame name.", "simple.the-name")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.wrong-name", String.class)
            .withDeprecation("Lame name.", "simple.the-name"));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writePropertyDeprecation(ItemMetadata... items) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();

    JSONArray propertiesArray = new JSONArray();
    for (ItemMetadata item : items) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", item.getName());
        if (item.getType() != null) {
            jsonObject.put("type", item.getType());
        }
        ItemDeprecation deprecation = item.getDeprecation();
        if (deprecation != null) {
            JSONObject deprecationJson = new JSONObject();
            if (deprecation.getReason() != null) {
                deprecationJson.put("reason", deprecation.getReason());
            }
            if (deprecation.getReplacement() != null) {
                deprecationJson.put("replacement", deprecation.getReplacement());
            }
            jsonObject.put("deprecation", deprecationJson);
        }
        propertiesArray.put(jsonObject);

    }
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("properties", propertiesArray);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessor.java   
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
    AnnotationMirror annotation = getAnnotation(getter,
            deprecatedConfigurationPropertyAnnotation());
    String reason = null;
    String replacement = null;
    if (annotation != null) {
        Map<String, Object> elementValues = getAnnotationElementValues(annotation);
        reason = (String) elementValues.get("reason");
        replacement = (String) elementValues.get("replacement");
    }
    return new ItemDeprecation(("".equals(reason) ? null : reason),
            ("".equals(replacement) ? null : replacement));
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessor.java   
private void processSimpleLombokTypes(String prefix, TypeElement element,
        TypeElementMembers members, Map<String, Object> fieldValues) {
    for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
        String name = entry.getKey();
        VariableElement field = entry.getValue();
        if (!isLombokField(field, element)) {
            continue;
        }
        TypeMirror returnType = field.asType();
        Element returnTypeElement = this.processingEnv.getTypeUtils()
                .asElement(returnType);
        boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
        boolean isNested = isNested(returnTypeElement, field, element);
        boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
        boolean hasSetter = hasLombokSetter(field, element);
        if (!isExcluded && !isNested && (hasSetter || isCollection)) {
            String dataType = this.typeUtils.getType(returnType);
            String sourceType = this.typeUtils.getType(element);
            String description = this.typeUtils.getJavaDoc(field);
            Object defaultValue = fieldValues.get(name);
            boolean deprecated = isDeprecated(field) || isDeprecated(element);
            this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
                    dataType, sourceType, null, description, defaultValue,
                    (deprecated ? new ItemDeprecation() : null)));
        }
    }
}
项目:spring-boot-concourse    文件:Metadata.java   
public MetadataItemCondition(ItemType itemType, String name, String type,
        Class<?> sourceType, String description, Object defaultValue,
        ItemDeprecation deprecation) {
    this.itemType = itemType;
    this.name = name;
    this.type = type;
    this.sourceType = sourceType;
    this.description = description;
    this.defaultValue = defaultValue;
    this.deprecation = deprecation;
    describedAs(createDescription());
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecation() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata)
            .has(Metadata.withProperty("simple.comparator", "java.util.Comparator<?>")
                    .fromSource(SimpleProperties.class)
                    .withDeprecation("Don't use this.", "simple.complex-comparator"));
    assertThat(metadata.getItems()).hasSize(4);
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecationOverride() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "single.name"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
    assertThat(metadata).has(
            Metadata.withProperty("singledeprecated.name", String.class.getName())
                    .fromSource(DeprecatedSingleProperty.class)
                    .withDeprecation("Don't use this.", "single.name"));
    assertThat(metadata.getItems()).hasSize(3);
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfAdditionalDeprecation() throws Exception {
    writePropertyDeprecation(ItemMetadata.newProperty("simple", "wrongName",
            "java.lang.String", null, null, null, null,
            new ItemDeprecation("Lame name.", "simple.the-name")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.wrong-name", String.class)
            .withDeprecation("Lame name.", "simple.the-name"));
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writePropertyDeprecation(ItemMetadata... items) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();

    JSONArray propertiesArray = new JSONArray();
    for (ItemMetadata item : items) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", item.getName());
        if (item.getType() != null) {
            jsonObject.put("type", item.getType());
        }
        ItemDeprecation deprecation = item.getDeprecation();
        if (deprecation != null) {
            JSONObject deprecationJson = new JSONObject();
            if (deprecation.getReason() != null) {
                deprecationJson.put("reason", deprecation.getReason());
            }
            if (deprecation.getReplacement() != null) {
                deprecationJson.put("replacement", deprecation.getReplacement());
            }
            jsonObject.put("deprecation", deprecationJson);
        }
        propertiesArray.put(jsonObject);

    }
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("properties", propertiesArray);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessor.java   
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
    AnnotationMirror annotation = getAnnotation(getter,
            deprecatedConfigurationPropertyAnnotation());
    String reason = null;
    String replacement = null;
    if (annotation != null) {
        Map<String, Object> elementValues = getAnnotationElementValues(annotation);
        reason = (String) elementValues.get("reason");
        replacement = (String) elementValues.get("replacement");
    }
    return new ItemDeprecation(("".equals(reason) ? null : reason),
            ("".equals(replacement) ? null : replacement));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessor.java   
private void processLombokTypes(String prefix, TypeElement element,
        TypeElementMembers members, Map<String, Object> fieldValues) {
    for (Map.Entry<String, VariableElement> entry : members.getFields().entrySet()) {
        String name = entry.getKey();
        VariableElement field = entry.getValue();
        if (!isLombokField(field, element)) {
            continue;
        }
        TypeMirror returnType = field.asType();
        Element returnTypeElement = this.processingEnv.getTypeUtils()
                .asElement(returnType);
        boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
        boolean isNested = isNested(returnTypeElement, field, element);
        boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
        boolean hasSetter = hasLombokSetter(field, element);
        if (!isExcluded && !isNested && (hasSetter || isCollection)) {
            String dataType = this.typeUtils.getType(returnType);
            String sourceType = this.typeUtils.getType(element);
            String description = this.typeUtils.getJavaDoc(field);
            Object defaultValue = fieldValues.get(name);
            boolean deprecated = isDeprecated(field) || isDeprecated(element);
            this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
                    dataType, sourceType, null, description, defaultValue,
                    (deprecated ? new ItemDeprecation() : null)));
        }
    }
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecation() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata,
            containsProperty("simple.comparator", "java.util.Comparator<?>")
                    .fromSource(SimpleProperties.class)
                    .withDeprecation("Don't use this.", "simple.complex-comparator"));
    assertThat(metadata.getItems().size(), is(4));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergeExistingPropertyDeprecationOverride() throws Exception {
    ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
            null, null, null, null,
            new ItemDeprecation("Don't use this.", "single.name"));
    writeAdditionalMetadata(property);
    ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
    assertThat(metadata,
            containsProperty("singledeprecated.name", String.class.getName())
                    .fromSource(DeprecatedSingleProperty.class)
                    .withDeprecation("Don't use this.", "single.name"));
    assertThat(metadata.getItems().size(), is(3));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfAdditionalDeprecation() throws Exception {
    writePropertyDeprecation(ItemMetadata.newProperty("simple", "wrongName",
            "java.lang.String", null, null, null, null,
            new ItemDeprecation("Lame name.", "simple.the-name")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata, containsProperty("simple.wrong-name", String.class)
            .withDeprecation("Lame name.", "simple.the-name"));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writePropertyDeprecation(ItemMetadata... items) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();

    JSONArray propertiesArray = new JSONArray();
    for (ItemMetadata item : items) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("name", item.getName());
        if (item.getType() != null) {
            jsonObject.put("type", item.getType());
        }
        ItemDeprecation deprecation = item.getDeprecation();
        if (deprecation != null) {
            JSONObject deprecationJson = new JSONObject();
            if (deprecation.getReason() != null) {
                deprecationJson.put("reason", deprecation.getReason());
            }
            if (deprecation.getReplacement() != null) {
                deprecationJson.put("replacement", deprecation.getReplacement());
            }
            jsonObject.put("deprecation", deprecationJson);
        }
        propertiesArray.put(jsonObject);

    }
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("properties", propertiesArray);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
public ContainsItemMatcher(ItemType itemType, String name, String type,
        Class<?> sourceType, String description, Matcher<?> defaultValue,
        ItemDeprecation deprecation) {
    this.itemType = itemType;
    this.name = name;
    this.type = type;
    this.sourceType = sourceType;
    this.description = description;
    this.defaultValue = defaultValue;
    this.deprecation = deprecation;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
public MetadataItemCondition withDeprecation(String reason, String replacement) {
    return new MetadataItemCondition(this.itemType, this.name, this.type,
            this.sourceType, this.description, this.defaultValue,
            new ItemDeprecation(reason, replacement));
}
项目:spring-boot-concourse    文件:Metadata.java   
public MetadataItemCondition withDeprecation(String reason, String replacement) {
    return new MetadataItemCondition(this.itemType, this.name, this.type,
            this.sourceType, this.description, this.defaultValue,
            new ItemDeprecation(reason, replacement));
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
public ContainsItemMatcher withDeprecation(String reason, String replacement) {
    return new ContainsItemMatcher(this.itemType, this.name, this.type,
            this.sourceType, this.description, this.defaultValue,
            new ItemDeprecation(reason, replacement));
}