Refine search
/** * Returns a {@link Attributes} instance based on the given {@link JsonObject}. * * @param claims a json object with the claims to extract * @return an {@link Attributes} instance with attributes from the given json object */ public static Attributes toAttributes(JsonObject claims) { return claims.entrySet().stream().reduce(new MapAttributes(), (mapAttributes, entry) -> { String claimName = entry.getKey(); JsonValue claimValue = entry.getValue(); if (JsonValue.ValueType.ARRAY.equals(claimValue.getValueType())) { JsonArray jsonArray = claims.getJsonArray(claimName); jsonArray.forEach(arrayValue -> mapAttributes.addLast(claimName, asString(arrayValue))); } else { mapAttributes.addLast(claimName, asString(claimValue)); } return mapAttributes; }, (mapAttributes, mapAttributes2) -> mapAttributes); }
private static int getJsonInt(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.NUMBER) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected number got %s", prop, ret.getValueType().name())); } return Integer.parseInt(ret.toString()); }
private static JsonObject getJsonObject(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.OBJECT) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected object got %s", prop, ret.getValueType().name())); } return ret.asJsonObject(); }
private static JsonArray getJsonArray(JsonObject obj, String prop) throws ChaincodeCollectionConfigurationException { JsonValue ret = obj.get(prop); if (ret == null) { throw new ChaincodeCollectionConfigurationException(format("property %s missing", prop)); } if (ret.getValueType() != JsonValue.ValueType.ARRAY) { throw new ChaincodeCollectionConfigurationException(format("property %s wrong type expected array got %s", prop, ret.getValueType().name())); } return ret.asJsonArray(); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
@Override public String toString() { return valueType.name().toLowerCase(); }
static String POINTER_REFERENCE_INVALID(JsonValue.ValueType type) { return localize("pointer.reference.invalid", type.name()); }
static String POINTER_REFERENCE_INVALID(JsonValue.ValueType type) { return localize("pointer.reference.invalid", type.name()); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
/** * Returns the hash code value for this {@link JsonValue#TRUE} object. * The hash code of the {@link JsonValue#TRUE} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this JsonString object */ @Override public int hashCode() { return ValueType.TRUE.hashCode(); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
@Override public String toString() { return valueType.name().toLowerCase(); }
/** * Returns the hash code value for this {@link JsonValue#NULL} object. * The hash code of the {@link JsonValue#NULL} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this JsonString object */ @Override public int hashCode() { return ValueType.NULL.hashCode(); }
/** * Returns the hash code value for this {@link JsonValue#FALSE} object. * The hash code of the {@link JsonValue#FALSE} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this JsonString object */ @Override public int hashCode() { return ValueType.FALSE.hashCode(); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
@Override public String toString() { return valueType.name().toLowerCase(); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
/** * Returns the hash code value for this {@link JsonValue} object. * The hash code of the {@link JsonValue} object is defined to be * its {@link #getValueType()} object's hash code. * * @return the hash code value for this {@link JsonValue} object */ @Override public int hashCode() { return valueType.hashCode(); }
@Override public int hashCode() { return ValueType.NULL.hashCode(); }
@Override public int hashCode() { return ValueType.FALSE.hashCode(); }