Search in sources :

Example 1 with CoercingStringValueSnapshot

use of org.gradle.api.internal.changedetection.state.CoercingStringValueSnapshot in project gradle by gradle.

the class AttributeContainerSerializer method read.

@Override
public ImmutableAttributes read(Decoder decoder) throws IOException {
    ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
    int count = decoder.readSmallInt();
    for (int i = 0; i < count; i++) {
        String name = decoder.readString();
        byte type = decoder.readByte();
        if (type == BOOLEAN_ATTRIBUTE) {
            attributes = attributesFactory.concat(attributes, Attribute.of(name, Boolean.class), decoder.readBoolean());
        } else {
            String value = decoder.readString();
            attributes = attributesFactory.concat(attributes, Attribute.of(name, String.class), new CoercingStringValueSnapshot(value, instantiator));
        }
    }
    return attributes;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) CoercingStringValueSnapshot(org.gradle.api.internal.changedetection.state.CoercingStringValueSnapshot)

Example 2 with CoercingStringValueSnapshot

use of org.gradle.api.internal.changedetection.state.CoercingStringValueSnapshot in project gradle by gradle.

the class ModuleMetadataParser method consumeAttributes.

private ImmutableAttributes consumeAttributes(JsonReader reader) throws IOException {
    ImmutableAttributes attributes = ImmutableAttributes.EMPTY;
    reader.beginObject();
    while (reader.peek() != END_OBJECT) {
        String attrName = reader.nextName();
        if (reader.peek() == BOOLEAN) {
            boolean attrValue = reader.nextBoolean();
            attributes = attributesFactory.concat(attributes, Attribute.of(attrName, Boolean.class), attrValue);
        } else {
            String attrValue = reader.nextString();
            attributes = attributesFactory.concat(attributes, Attribute.of(attrName, String.class), new CoercingStringValueSnapshot(attrValue, instantiator));
        }
    }
    reader.endObject();
    return attributes;
}
Also used : ImmutableAttributes(org.gradle.api.internal.attributes.ImmutableAttributes) CoercingStringValueSnapshot(org.gradle.api.internal.changedetection.state.CoercingStringValueSnapshot)

Aggregations

ImmutableAttributes (org.gradle.api.internal.attributes.ImmutableAttributes)2 CoercingStringValueSnapshot (org.gradle.api.internal.changedetection.state.CoercingStringValueSnapshot)2