/** * Get the result of an Object path expression as a list. * * @param path The Object path. * @param <T> The list type * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <T> List<T> getList(String path) { return get(path); }
/** * Get the result of an Object path expression as a map. * * @param path The Object path. * @param <K> The type of the expected key * @param <V> The type of the expected value * @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <K, V> Map<K, V> getMap(String path) { return get(path); }
/** * Get the result of an Object path expression as a map. * * @param path The Object path. * @param <K> The type of the expected key * @param <V> The type of the expected value * @return The map matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <K, V> Map<K, V> getMap(String path) { return get(path); }
/** * Get the result of an Object path expression as a list. * * @param path The Object path. * @param <T> The list type * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <T> List<T> getList(String path) { return get(path); }
/** * Get a Object graph with no named root element as a Java object. This is just a short-cut for * <p/> * <pre> * get(""); * </pre> * or * <pre> * get("$"); * </pre> * * @return The object matching the Object graph. This may be any primitive type, a List or a Map. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <T> T get() { return get(""); }
/** * Get a Object graph with no named root element as a Java object. This is just a short-cut for * <p/> * <pre> * get(""); * </pre> * or * <pre> * get("$"); * </pre> * * @return The object matching the Object graph. This may be any primitive type, a List or a Map. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public <T> T get() { return get(""); }
/** * Get the result of an Object path expression as a char. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public char getChar(String path) { return ObjectConverter.convertObjectTo(get(path), Character.class); }
/** * Get the result of an Object path expression as a string. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public String getString(String path) { return ObjectConverter.convertObjectTo(get(path), String.class); }
/** * Get the result of an Object path expression as a UUID. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public UUID getUUID(String path) { return ObjectConverter.convertObjectTo(get(path), UUID.class); }
/** * Get the result of an Object path expression as a boolean * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public boolean getBoolean(String path) { return ObjectConverter.convertObjectTo(get(path), Boolean.class); }
/** * Get the result of an Object path expression as a UUID. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public UUID getUUID(String path) { return ObjectConverter.convertObjectTo(get(path), UUID.class); }
/** * Get the result of an Object path expression as a boolean * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public boolean getBoolean(String path) { return ObjectConverter.convertObjectTo(get(path), Boolean.class); }
/** * Get the result of an Object path expression as a char. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public char getChar(String path) { return ObjectConverter.convertObjectTo(get(path), Character.class); }
/** * Get the result of an Object path expression as a string. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public String getString(String path) { return ObjectConverter.convertObjectTo(get(path), String.class); }
/** * Get the result of an Object path expression as a double. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public double getDouble(String path) { final Object value = get(path); if (value instanceof Double) { return (Double) value; } return ObjectConverter.convertObjectTo(value, Double.class); }
/** * Get the result of an Object path expression as a double. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public double getDouble(String path) { final Object value = get(path); if (value instanceof Double) { return (Double) value; } return ObjectConverter.convertObjectTo(value, Double.class); }
/** * Get the result of an Object path expression as a float. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public float getFloat(String path) { final Object value = get(path); //Groovy will always return a Double for floating point values. if (value instanceof Double) { return ((Double) value).floatValue(); } else { return ObjectConverter.convertObjectTo(value, Float.class); } }
/** * Get the result of an Object path expression as a float. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public float getFloat(String path) { final Object value = get(path); //Groovy will always return a Double for floating point values. if (value instanceof Double) { return ((Double) value).floatValue(); } else { return ObjectConverter.convertObjectTo(value, Float.class); } }
/** * Get the result of an Object path expression as a long. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public long getLong(String path) { //The type returned from Groovy depends on the input, so we need to handle different numerical types. Object value = get(path); if (value instanceof Long) { return (Long) value; } else if (value instanceof Short) { return ((Short) value).longValue(); } else if (value instanceof Integer) { return ((Integer) value).longValue(); } else { return ObjectConverter.convertObjectTo(value, Long.class); } }
/** * Get the result of an Object path expression as a short. * * @param path The Object path. * @return The object matching the Object path. A {@link java.lang.ClassCastException} will be thrown if the object * cannot be casted to the expected type. */ public short getShort(String path) { //The type returned from Groovy depends on the input, so we need to handle different numerical types. Object value = get(path); if (value instanceof Short) { return (Short) value; } else if (value instanceof Long) { return ((Long) value).shortValue(); } else if (value instanceof Integer) { return ((Integer) value).shortValue(); } else { return ObjectConverter.convertObjectTo(value, Short.class); } }