All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sixpointsix.carpo.common.model.PropertyCollection Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package net.sixpointsix.carpo.common.model;

import java.util.Collection;
import java.util.List;
import java.util.Optional;

/**
 * Collection of properties within an entity
 *
 * @author Andrew Tarry
 * @since 0.0.1
 */
public interface PropertyCollection extends Collection {

    /**
     * Get a property by its key
     *
     * @param key property key
     * @return Property optional, empty if the key is not set
     */
    Optional getByKey(String key);

    /**
     * Test if a property exists with a key
     *
     * @param key property key
     * @return True if the property exists
     */
    Boolean hasPropertyByKey(String key);

    /**
     * Get the string value if it exists
     *
     * 

* This method will get the string value and will return an empty optional if the property with key does not * exist or the value is not a string *

* * @param key property key * @return optional string */ Optional getStringByKey(String key); /** * Get the long value if it exists * *

* This method will get the long value and will return an empty optional if the property with key does not * exist or the value is not a long *

* * @param key property key * @return optional long */ Optional getLongByKey(String key); /** * Get the double value if it exists * *

* This method will get the double value and will return an empty optional if the property with key does not * exist or the value is not a double *

* * @param key property key * @return optional double */ Optional getDoubleByKey(String key); /** * Get the boolean value if it exists * *

* This method will get the boolean value and will return an empty optional if the property with key does not * exist or the value is not a boolean *

* * @param key property key * @return optional boolean */ Optional getBooleanByKey(String key); /** * Get the object value if it exists * *

* This method will get the object value and will return an empty optional if the property with key does not * exist or the value is not a object or it cannot be cast to T *

* * @param key property key * @param type type to cast to * @param type to cast to * @return optional object */ Optional getObjectByKey(String key, Class type); /** * Get the object values as a list * *

* This method will get the list of object values and will return an empty list if the property with key does * not exist. Each element will be cast a T and only the successful ones will be returned *

* * @param key property key * @param type type to cast to * @param type to cast to * @return list of object */ List getListByKey(String key, Class type); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy