Search in sources :

Example 1 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class ValuedListPropertyTest method describeDefault.

@Test
public void describeDefault() {
    Property testProperty = new TestListProperty("key", emptyList());
    Assertions.assertNotNull(testProperty.describeDefault(), "The default value description should be set.");
}
Also used : Property(com.synopsys.integration.configuration.property.Property) Test(org.junit.jupiter.api.Test)

Example 2 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class DetectProperties method allProperties.

// Accessor to get all properties
public static Properties allProperties() {
    List<Property> properties = new ArrayList<>();
    Field[] allFields = DetectProperties.class.getDeclaredFields();
    for (Field field : allFields) {
        if (Property.class.isAssignableFrom(field.getType())) {
            try {
                Object property = field.get(Property.class);
                Property detectProperty = (Property) property;
                properties.add(detectProperty);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }
    }
    return new Properties(properties);
}
Also used : Field(java.lang.reflect.Field) ArrayList(java.util.ArrayList) Properties(com.synopsys.integration.configuration.property.Properties) ExtendedEnumProperty(com.synopsys.integration.configuration.property.types.enumextended.ExtendedEnumProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) TypedProperty(com.synopsys.integration.configuration.property.base.TypedProperty) NullablePathProperty(com.synopsys.integration.configuration.property.types.path.NullablePathProperty) LongProperty(com.synopsys.integration.configuration.property.types.longs.LongProperty) NullableIntegerProperty(com.synopsys.integration.configuration.property.types.integer.NullableIntegerProperty) PathListProperty(com.synopsys.integration.configuration.property.types.path.PathListProperty) Property(com.synopsys.integration.configuration.property.Property) EnumProperty(com.synopsys.integration.configuration.property.types.enums.EnumProperty) CaseSensitiveStringListProperty(com.synopsys.integration.configuration.property.types.string.CaseSensitiveStringListProperty) StringListProperty(com.synopsys.integration.configuration.property.types.string.StringListProperty) AllNoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty) IntegerProperty(com.synopsys.integration.configuration.property.types.integer.IntegerProperty) EnumListProperty(com.synopsys.integration.configuration.property.types.enums.EnumListProperty) BooleanProperty(com.synopsys.integration.configuration.property.types.bool.BooleanProperty) StringProperty(com.synopsys.integration.configuration.property.types.string.StringProperty) NoneEnumListProperty(com.synopsys.integration.configuration.property.types.enumallnone.property.NoneEnumListProperty) NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty)

Example 3 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class HelpPrinter method printOptions.

public void printOptions(HelpTextWriter writer, List<Property> options, String notes) {
    writer.printColumns("Property Name", "Default", "Description");
    writer.printSeparator();
    List<Property> sorted = options.stream().sorted(SORT_BY_GROUP_THEN_KEY).collect(Collectors.toList());
    if (notes != null) {
        writer.println(notes);
        writer.println();
    }
    String group = null;
    for (Property detectOption : sorted) {
        String currentGroup = detectOption.getPropertyGroupInfo().getPrimaryGroup().getName();
        if (group == null) {
            group = currentGroup;
            writer.println("[" + group + "]");
        } else if (!group.equals(currentGroup)) {
            group = currentGroup;
            writer.println();
            writer.println("[" + group + "]");
        }
        printOption(writer, detectOption);
    }
}
Also used : Property(com.synopsys.integration.configuration.property.Property)

Example 4 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class PropertyConfiguration method getMaskedRawValueMap.

@NotNull
public Map<String, String> getMaskedRawValueMap(@NotNull Set<Property> properties, Predicate<String> shouldMask) {
    Map<String, String> rawMap = new HashMap<>();
    for (Property property : properties) {
        String rawKey = property.getKey();
        if (property instanceof PassthroughProperty) {
            getRaw((PassthroughProperty) property).entrySet().forEach(passThrough -> {
                String fullPassThroughKey = String.format("%s.%s", rawKey, passThrough.getKey());
                rawMap.put(fullPassThroughKey, maskValue(fullPassThroughKey, passThrough.getValue(), shouldMask));
            });
        } else {
            getRaw(property).ifPresent(rawValue -> rawMap.put(rawKey, maskValue(rawKey, rawValue, shouldMask)));
        }
    }
    return rawMap;
}
Also used : HashMap(java.util.HashMap) NullableProperty(com.synopsys.integration.configuration.property.base.NullableProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) TypedProperty(com.synopsys.integration.configuration.property.base.TypedProperty) ValuedProperty(com.synopsys.integration.configuration.property.base.ValuedProperty) Property(com.synopsys.integration.configuration.property.Property) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with Property

use of com.synopsys.integration.configuration.property.Property in project synopsys-detect by blackducksoftware.

the class PropertyConfigurationTest method testPropertyIsDeprecated.

@Test
public void testPropertyIsDeprecated() {
    Property property1 = new NullableStringProperty("name");
    property1.setRemovalDeprecation("desc", new ProductMajorVersion(1));
    Assertions.assertTrue(property1.isDeprecatedForRemoval());
    Property property2 = new NullableStringProperty("name");
    property2.addDeprecatedValueInfo("val", "reason");
    Assertions.assertFalse(property2.isDeprecatedForRemoval());
}
Also used : NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) NullableAlikeProperty(com.synopsys.integration.configuration.property.base.NullableAlikeProperty) Property(com.synopsys.integration.configuration.property.Property) ValuedAlikeProperty(com.synopsys.integration.configuration.property.base.ValuedAlikeProperty) PassthroughProperty(com.synopsys.integration.configuration.property.base.PassthroughProperty) NullableStringProperty(com.synopsys.integration.configuration.property.types.string.NullableStringProperty) ProductMajorVersion(com.synopsys.integration.configuration.util.ProductMajorVersion) Test(org.junit.jupiter.api.Test)

Aggregations

Property (com.synopsys.integration.configuration.property.Property)8 PassthroughProperty (com.synopsys.integration.configuration.property.base.PassthroughProperty)4 Test (org.junit.jupiter.api.Test)4 TypedProperty (com.synopsys.integration.configuration.property.base.TypedProperty)3 NullableStringProperty (com.synopsys.integration.configuration.property.types.string.NullableStringProperty)3 NullableAlikeProperty (com.synopsys.integration.configuration.property.base.NullableAlikeProperty)2 ValuedAlikeProperty (com.synopsys.integration.configuration.property.base.ValuedAlikeProperty)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ValueParseException (com.synopsys.integration.configuration.parse.ValueParseException)1 Properties (com.synopsys.integration.configuration.property.Properties)1 NullableProperty (com.synopsys.integration.configuration.property.base.NullableProperty)1 ValuedProperty (com.synopsys.integration.configuration.property.base.ValuedProperty)1 BooleanProperty (com.synopsys.integration.configuration.property.types.bool.BooleanProperty)1 AllNoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.AllNoneEnumListProperty)1 NoneEnumListProperty (com.synopsys.integration.configuration.property.types.enumallnone.property.NoneEnumListProperty)1 ExtendedEnumProperty (com.synopsys.integration.configuration.property.types.enumextended.ExtendedEnumProperty)1 EnumListProperty (com.synopsys.integration.configuration.property.types.enums.EnumListProperty)1 EnumProperty (com.synopsys.integration.configuration.property.types.enums.EnumProperty)1 IntegerProperty (com.synopsys.integration.configuration.property.types.integer.IntegerProperty)1