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

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
@Override
public boolean matches(ItemHint hint) {
    if (this.index + 1 > hint.getProviders().size()) {
        return false;
    }
    ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
    if (this.name != null && !this.name.equals(valueProvider.getName())) {
        return false;
    }
    if (this.parameters != null) {
        for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
            if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
                    .matches(valueProvider.getParameters())) {
                return false;
            }
        }
    }
    return true;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithProvider() throws Exception {
    writeAdditionalHints(new ItemHint("simple.theName",
            Collections.<ItemHint.ValueHint>emptyList(),
            Arrays.asList(
                    new ItemHint.ValueProvider("first",
                            Collections.<String, Object>singletonMap("target",
                                    "org.foo")),
                    new ItemHint.ValueProvider("second", null))));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withHint("simple.the-name")
            .withProvider("first", "target", "org.foo").withProvider("second"));
}
项目:spring-boot-concourse    文件:Metadata.java   
@Override
public boolean matches(ItemHint hint) {
    if (this.index + 1 > hint.getProviders().size()) {
        return false;
    }
    ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
    if (this.name != null && !this.name.equals(valueProvider.getName())) {
        return false;
    }
    if (this.parameters != null) {
        for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
            if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
                    .matches(valueProvider.getParameters())) {
                return false;
            }
        }
    }
    return true;
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithProvider() throws Exception {
    writeAdditionalHints(new ItemHint("simple.theName",
            Collections.<ItemHint.ValueHint>emptyList(),
            Arrays.asList(
                    new ItemHint.ValueProvider("first",
                            Collections.<String, Object>singletonMap("target",
                                    "org.foo")),
                    new ItemHint.ValueProvider("second", null))));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withHint("simple.the-name")
            .withProvider("first", "target", "org.foo").withProvider("second"));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithProvider() throws Exception {
    writeAdditionalHints(new ItemHint("simple.theName",
            Collections.<ItemHint.ValueHint>emptyList(),
            Arrays.asList(
                    new ItemHint.ValueProvider("first",
                            Collections.<String, Object>singletonMap("target",
                                    "org.foo")),
                    new ItemHint.ValueProvider("second", null))));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata,
            containsProperty("simple.the-name", String.class)
                    .fromSource(SimpleProperties.class)
                    .withDescription("The name of this simple properties.")
                    .withDefaultValue(is("boot")).withDeprecation(null, null));
    assertThat(metadata, containsHint("simple.the-name")
            .withProvider("first", "target", "org.foo").withProvider("second"));
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
@Override
public boolean matches(Object item) {
    ConfigurationMetadata metadata = (ConfigurationMetadata) item;
    ItemHint itemHint = getFirstHintWithName(metadata, this.name);
    if (itemHint == null) {
        return false;
    }
    for (ValueHintMatcher value : this.values) {
        if (!value.matches(itemHint)) {
            return false;
        }
    }
    for (ValueProviderMatcher provider : this.providers) {
        if (!provider.matches(itemHint)) {
            return false;
        }
    }
    return true;
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
@Override
public boolean matches(Object item) {
    ItemHint hint = (ItemHint) item;
    if (this.index + 1 > hint.getValues().size()) {
        return false;
    }
    ItemHint.ValueHint valueHint = hint.getValues().get(this.index);
    if (this.value != null && !this.value.equals(valueHint.getValue())) {
        return false;
    }
    if (this.description != null
            && !this.description.equals(valueHint.getDescription())) {
        return false;
    }
    return true;
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
@Override
public boolean matches(Object item) {
    ItemHint hint = (ItemHint) item;
    if (this.index + 1 > hint.getProviders().size()) {
        return false;
    }
    ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
    if (this.name != null && !this.name.equals(valueProvider.getName())) {
        return false;
    }
    if (this.parameters != null) {
        for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
            if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
                    .matches(valueProvider.getParameters())) {
                return false;
            }
        }
    }
    return true;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
@Override
public boolean matches(ConfigurationMetadata metadata) {
    ItemHint itemHint = getFirstHintWithName(metadata, this.name);
    if (itemHint == null) {
        return false;
    }
    return matches(itemHint, this.valueConditions)
            && matches(itemHint, this.providerConditions);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
private boolean matches(ItemHint itemHint,
        List<? extends Condition<ItemHint>> conditions) {
    for (Condition<ItemHint> condition : conditions) {
        if (!condition.matches(itemHint)) {
            return false;
        }
    }
    return true;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
        String name) {
    for (ItemHint hint : metadata.getHints()) {
        if (name.equals(hint.getName())) {
            return hint;
        }
    }
    return null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
@Override
public boolean matches(ItemHint value) {
    if (this.index + 1 > value.getValues().size()) {
        return false;
    }
    ItemHint.ValueHint valueHint = value.getValues().get(this.index);
    if (this.value != null && !this.value.equals(valueHint.getValue())) {
        return false;
    }
    if (this.description != null
            && !this.description.equals(valueHint.getDescription())) {
        return false;
    }
    return true;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfSimpleHint() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.the-name",
            new ItemHint.ValueHint("boot", "Bla bla"),
            new ItemHint.ValueHint("spring", null)));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withHint("simple.the-name")
            .withValue(0, "boot", "Bla bla").withValue(1, "spring", null));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.theName",
            new ItemHint.ValueHint("boot", "Bla bla")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(
            Metadata.withHint("simple.the-name").withValue(0, "boot", "Bla bla"));
}
项目:spring-boot-concourse    文件:Metadata.java   
@Override
public boolean matches(ConfigurationMetadata metadata) {
    ItemHint itemHint = getFirstHintWithName(metadata, this.name);
    if (itemHint == null) {
        return false;
    }
    return matches(itemHint, this.valueConditions)
            && matches(itemHint, this.providerConditions);
}
项目:spring-boot-concourse    文件:Metadata.java   
private boolean matches(ItemHint itemHint,
        List<? extends Condition<ItemHint>> conditions) {
    for (Condition<ItemHint> condition : conditions) {
        if (!condition.matches(itemHint)) {
            return false;
        }
    }
    return true;
}
项目:spring-boot-concourse    文件:Metadata.java   
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
        String name) {
    for (ItemHint hint : metadata.getHints()) {
        if (name.equals(hint.getName())) {
            return hint;
        }
    }
    return null;
}
项目:spring-boot-concourse    文件:Metadata.java   
@Override
public boolean matches(ItemHint value) {
    if (this.index + 1 > value.getValues().size()) {
        return false;
    }
    ItemHint.ValueHint valueHint = value.getValues().get(this.index);
    if (this.value != null && !this.value.equals(valueHint.getValue())) {
        return false;
    }
    if (this.description != null
            && !this.description.equals(valueHint.getDescription())) {
        return false;
    }
    return true;
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfSimpleHint() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.the-name",
            new ItemHint.ValueHint("boot", "Bla bla"),
            new ItemHint.ValueHint("spring", null)));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(Metadata.withHint("simple.the-name")
            .withValue(0, "boot", "Bla bla").withValue(1, "spring", null));
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.theName",
            new ItemHint.ValueHint("boot", "Bla bla")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata).has(Metadata.withProperty("simple.the-name", String.class)
            .fromSource(SimpleProperties.class)
            .withDescription("The name of this simple properties.")
            .withDefaultValue("boot").withDeprecation(null, null));
    assertThat(metadata).has(
            Metadata.withHint("simple.the-name").withValue(0, "boot", "Bla bla"));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfSimpleHint() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.the-name",
            new ItemHint.ValueHint("boot", "Bla bla"),
            new ItemHint.ValueHint("spring", null)));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata,
            containsProperty("simple.the-name", String.class)
                    .fromSource(SimpleProperties.class)
                    .withDescription("The name of this simple properties.")
                    .withDefaultValue(is("boot")).withDeprecation(null, null));
    assertThat(metadata, containsHint("simple.the-name")
            .withValue(0, "boot", "Bla bla").withValue(1, "spring", null));
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
@Test
public void mergingOfHintWithNonCanonicalName() throws Exception {
    writeAdditionalHints(ItemHint.newHint("simple.theName",
            new ItemHint.ValueHint("boot", "Bla bla")));
    ConfigurationMetadata metadata = compile(SimpleProperties.class);
    assertThat(metadata,
            containsProperty("simple.the-name", String.class)
                    .fromSource(SimpleProperties.class)
                    .withDescription("The name of this simple properties.")
                    .withDefaultValue(is("boot")).withDeprecation(null, null));
    assertThat(metadata,
            containsHint("simple.the-name").withValue(0, "boot", "Bla bla"));
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
@Override
public void describeMismatch(Object item, Description description) {
    ConfigurationMetadata metadata = (ConfigurationMetadata) item;
    ItemHint itemHint = getFirstHintWithName(metadata, this.name);
    if (itemHint == null) {
        description.appendText("missing hint " + this.name);
    }
    else {
        description.appendText("was hint ").appendValue(itemHint);
    }
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
        String name) {
    for (ItemHint hint : metadata.getHints()) {
        if (name.equals(hint.getName())) {
            return hint;
        }
    }
    return null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writeAdditionalHints(ItemHint... hints) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("hints", hints);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
项目:spring-boot-concourse    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writeAdditionalHints(ItemHint... hints) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("hints", hints);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}
项目:contestparser    文件:ConfigurationMetadataAnnotationProcessorTests.java   
private void writeAdditionalHints(ItemHint... hints) throws IOException {
    File additionalMetadataFile = createAdditionalMetadataFile();
    JSONObject additionalMetadata = new JSONObject();
    additionalMetadata.put("hints", hints);
    writeMetadata(additionalMetadataFile, additionalMetadata);
}