src/main/java/org/intellimate/izou/sdk/frameworks/presence/provider/Presence.java
public static Optional<Presence> importPresence(ResourceModel resourceModel) {
        Object resource = resourceModel.getResource();
        try {
            //noinspection unchecked
            HashMap<String, Object> data = (HashMap<String, Object>) resource;
            PresenceIndicatorLevel level;
            try {
                level = PresenceIndicatorLevel.valueOf((String) data.get(LEVEL_DESCRIPTOR));
            } catch (IllegalArgumentException e) {
                level = PresenceIndicatorLevel.VERY_WEAK;
            }
            boolean present = (boolean) data.get(PRESENT_DESCRIPTOR);
            boolean strict = (boolean) data.get(STRICT_DESCRIPTOR);
            boolean known = (boolean) data.get(KNOWN_DESCRIPTOR);
            return Optional.of(new Presence(level, present, strict, known));
        } catch (Exception e) {
            return Optional.empty();
        }
    }
public static Optional<Presence> importPresence(ResourceModel resourceModel) {
        Object resource = resourceModel.getResource();
        try {
            //noinspection unchecked
            HashMap<String, Object> data = (HashMap<String, Object>) resource;
            PresenceIndicatorLevel level;
            try {
                level = PresenceIndicatorLevel.valueOf((String) data.get(LEVEL_DESCRIPTOR));
            } catch (IllegalArgumentException e) {
                level = PresenceIndicatorLevel.VERY_WEAK;
            }
            boolean present = (boolean) data.get(PRESENT_DESCRIPTOR);
            boolean strict = (boolean) data.get(STRICT_DESCRIPTOR);
            boolean known = (boolean) data.get(KNOWN_DESCRIPTOR);
            return Optional.of(new Presence(level, present, strict, known));
        } catch (Exception e) {
            return Optional.empty();
        }
    }
public static Optional < Presence > importPresence ( ResourceModel resourceModel ) { Object resource = resourceModel . getResource ( ) ; try { //noinspection unchecked HashMap < String , Object > data = ( HashMap < String , Object > ) resource ; PresenceIndicatorLevel level ; try { level = PresenceIndicatorLevel . valueOf ( ( String ) data . get ( LEVEL_DESCRIPTOR ) ) ; } catch ( IllegalArgumentException e ) { level = PresenceIndicatorLevel . VERY_WEAK ; } boolean present = ( boolean ) data . get ( PRESENT_DESCRIPTOR ) ; boolean strict = ( boolean ) data . get ( STRICT_DESCRIPTOR ) ; boolean known = ( boolean ) data . get ( KNOWN_DESCRIPTOR ) ; return Optional . of ( new Presence ( level , present , strict , known ) ) ; } catch ( Exception e ) { return Optional . empty ( ) ; } }
imports (if no errors occurred) the Presence from the ResourceModel
@param resourceModel the resourcemodel to import from
@return the (optional) presence
imports ( if no errors occurred ) the Presence from the ResourceModel