@Test public void toTypedValues() { UntypedValues untypedValues = UntypedValues.builder() .timestamp(13L) .prefix("") .source("test") .values(Collections.singletonMap("key", 42L)) .build(); TypedValues typedValues = untypedValues.toTypedValues(); assertEquals(untypedValues.getTimestamp(), typedValues.getTimestamp()); assertEquals(untypedValues.getSource(), typedValues.getSource()); assertTrue(LongValue.class.isAssignableFrom(typedValues.getValues().get("key").getClass())); assertEquals(42L, untypedValues.getValues().get("key")); }
public TypedValues toTypedValues() { Map<String, Value> valueMap = new HashMap<>(); for (Map.Entry<String, Object> entry : values.entrySet()) { String channelName = entry.getKey(); if (prefix != null && !prefix.isEmpty()) { channelName = prefix + "_" + entry.getKey(); } valueMap.put(channelName, Value.of(entry.getValue())); } return new TypedValues(source, timestamp, valueMap); }
UntypedValues implements MRecord { public TypedValues toTypedValues() { Map<String, Value> valueMap = new HashMap<>(); for (Map.Entry<String, Object> entry : values.entrySet()) { String channelName = entry.getKey(); if (prefix != null && !prefix.isEmpty()) { channelName = prefix + "_" + entry.getKey(); } valueMap.put(channelName, Value.of(entry.getValue())); } return new TypedValues(source, timestamp, valueMap); } }
UntypedValues implements MRecord { public TypedValues toTypedValues() { Map<String, Value> valueMap = new HashMap<>(); for (Map.Entry<String, Object> entry : values.entrySet()) { String channelName = entry.getKey(); if (prefix != null && !prefix.isEmpty()) { channelName = prefix + "_" + entry.getKey(); } valueMap.put(channelName, Value.of(entry.getValue())); } return new TypedValues(source, timestamp, valueMap); } UntypedValues(
            String source, long timestamp, String prefix, Map<String, Object> values
    ); }
UntypedValues implements MRecord { public TypedValues toTypedValues() { Map<String, Value> valueMap = new HashMap<>(); for (Map.Entry<String, Object> entry : values.entrySet()) { String channelName = entry.getKey(); if (prefix != null && !prefix.isEmpty()) { channelName = prefix + "_" + entry.getKey(); } valueMap.put(channelName, Value.of(entry.getValue())); } return new TypedValues(source, timestamp, valueMap); } UntypedValues(
            String source, long timestamp, String prefix, Map<String, Object> values
    ); @Override Double getDouble(String channel); @Override Long getLong(String channel); @Override @SuppressWarnings("squid:S2447") // null should not be returned, in this case it is necessary Boolean getBoolean(String channel); @Override Date getDate(String channel); @Override String getString(String channel); @Override Value getValue(String channel); @Override Object get(String channel); @Override @JsonIgnore Collection<String> getChannels(); TypedValues toTypedValues(); UntypedValues filterChannels(Set<String> channels); @JsonIgnore // prevent interpretation as a getter boolean isEmpty(); String getPrefix(); Map<String, Object> getValues(); void setValues(Map<String, Object> values); UntypedValues merge(UntypedValues untypedValues); static Builder builder(); }
UntypedValues implements MRecord { public TypedValues toTypedValues() { Map<String, Value> valueMap = new HashMap<>(); for (Map.Entry<String, Object> entry : values.entrySet()) { String channelName = entry.getKey(); if (prefix != null && !prefix.isEmpty()) { channelName = prefix + "_" + entry.getKey(); } valueMap.put(channelName, Value.of(entry.getValue())); } return new TypedValues(source, timestamp, valueMap); } UntypedValues(
            String source, long timestamp, String prefix, Map<String, Object> values
    ); @Override Double getDouble(String channel); @Override Long getLong(String channel); @Override @SuppressWarnings("squid:S2447") // null should not be returned, in this case it is necessary Boolean getBoolean(String channel); @Override Date getDate(String channel); @Override String getString(String channel); @Override Value getValue(String channel); @Override Object get(String channel); @Override @JsonIgnore Collection<String> getChannels(); TypedValues toTypedValues(); UntypedValues filterChannels(Set<String> channels); @JsonIgnore // prevent interpretation as a getter boolean isEmpty(); String getPrefix(); Map<String, Object> getValues(); void setValues(Map<String, Object> values); UntypedValues merge(UntypedValues untypedValues); static Builder builder();  }