@Override public Set<String> keys() { return Sets.difference(delegate.keys(), filtered); }
/** * Produces a JSON object from the specified key/value annotations. * * @param mapper ObjectMapper to use while converting to JSON * @param annotations key/value annotations * @return JSON object */ public static ObjectNode annotations(ObjectMapper mapper, Annotations annotations) { ObjectNode result = mapper.createObjectNode(); for (String key : annotations.keys()) { result.put(key, annotations.value(key)); } return result; }
private boolean containsSuppressionAnnotation(final Annotations annotations) { for (Entry<String, String> entry : suppressedAnnotation.entrySet()) { final String suppValue = entry.getValue(); final String suppKey = entry.getKey(); if (suppValue == ANY_VALUE) { if (annotations.keys().contains(suppKey)) { return true; } } else { if (suppValue.equals(annotations.value(suppKey))) { return true; } } } return false; }
/** * Produces a string image of the specified key/value annotations. * * @param annotations key/value annotations * @return string image with ", k1=v1, k2=v2, ..." pairs */ public static String annotations(Annotations annotations) { if (annotations == null) { annotations = DefaultAnnotations.EMPTY; } StringBuilder sb = new StringBuilder(); Set<String> keys = new TreeSet<>(annotations.keys()); for (String key : keys) { sb.append(", ").append(key).append('=').append(annotations.value(key)); } return sb.toString(); }
/** * Produces a string image of the specified key/value annotations. * Excludes the keys in the given Set. * * @param annotations key/value annotations * @param excludedKeys keys not to add in the resulting string * @return string image with ", k1=v1, k2=v2, ..." pairs */ public static String annotations(Annotations annotations, Set<String> excludedKeys) { StringBuilder sb = new StringBuilder(); Set<String> keys = new TreeSet<>(annotations.keys()); keys.removeAll(excludedKeys); for (String key : keys) { sb.append(", ").append(key).append('=').append(annotations.value(key)); } return sb.toString(); }
@Override public ObjectNode encode(Annotations annotations, CodecContext context) { ObjectNode result = context.mapper().createObjectNode(); Set<String> keys = new TreeSet<>(annotations.keys()); for (String key : keys) { result.put(key, annotations.value(key)); } return result; }
private DomainId getAnnotatedDomainId(Device device) { if (!device.annotations().keys().contains(DOMAIN_ID)) { return DomainId.LOCAL; } else { return DomainId.domainId( device.annotations().value(DOMAIN_ID)); } } }
/** * Adds JSON encoding of the given item annotations to the specified node. * * @param node node to add annotations to * @param entity annotated entity * @param context encode context * @return the given node */ protected ObjectNode annotate(ObjectNode node, T entity, CodecContext context) { if (!entity.annotations().keys().isEmpty()) { JsonCodec<Annotations> codec = context.codec(Annotations.class); node.set("annotations", codec.encode(entity.annotations(), context)); } return node; }