public Object compactValue(String activeProperty, Map<String, Object> value) {
        // 1)
        int numberMembers = value.size();
        // 2)
        if (value.containsKey(JsonLdConsts.INDEX)
                && JsonLdConsts.INDEX.equals(this.getContainer(activeProperty))) {
            numberMembers--;
        }
        // 3)
        if (numberMembers > 2) {
            return value;
        }
        // 4)
        final String typeMapping = getTypeMapping(activeProperty);
        final String languageMapping = getLanguageMapping(activeProperty);
        if (value.containsKey(JsonLdConsts.ID)) {
            // 4.1)
            if (numberMembers == 1 && JsonLdConsts.ID.equals(typeMapping)) {
                return compactIri((String) value.get(JsonLdConsts.ID));
            }
            // 4.2)
            if (numberMembers == 1 && JsonLdConsts.VOCAB.equals(typeMapping)) {
                return compactIri((String) value.get(JsonLdConsts.ID), true);
            }
            // 4.3)
            return value;
        }
        final Object valueValue = value.get(JsonLdConsts.VALUE);
        // 5)
        if (value.containsKey(JsonLdConsts.TYPE)
                && Obj.equals(value.get(JsonLdConsts.TYPE), typeMapping)) {
            return valueValue;
        }
        // 6)
        if (value.containsKey(JsonLdConsts.LANGUAGE)) {
            // TODO: SPEC: doesn't specify to check default language as well
            if (Obj.equals(value.get(JsonLdConsts.LANGUAGE), languageMapping) || Obj
                    .equals(value.get(JsonLdConsts.LANGUAGE), this.get(JsonLdConsts.LANGUAGE))) {
                return valueValue;
            }
        }
        // 7)
        if (numberMembers == 1 && (!(valueValue instanceof String)
                || !this.containsKey(JsonLdConsts.LANGUAGE)
                || (termDefinitions.containsKey(activeProperty)
                        && getTermDefinition(activeProperty).containsKey(JsonLdConsts.LANGUAGE)
                        && languageMapping == null))) {
            return valueValue;
        }
        // 8)
        return value;
    }
public Object compactValue ( String activeProperty , Map < String , Object > value ) { int numberMembers = value . size ( ) ; if ( value . containsKey ( JsonLdConsts . INDEX ) && JsonLdConsts . INDEX . equals ( this . getContainer ( activeProperty ) ) ) { numberMembers -- ; } if ( numberMembers > 2 ) { return value ; } final String typeMapping = getTypeMapping ( activeProperty ) ; final String languageMapping = getLanguageMapping ( activeProperty ) ; if ( value . containsKey ( JsonLdConsts . ID ) ) { if ( numberMembers == 1 && JsonLdConsts . ID . equals ( typeMapping ) ) { return compactIri ( ( String ) value . get ( JsonLdConsts . ID ) ) ; } if ( numberMembers == 1 && JsonLdConsts . VOCAB . equals ( typeMapping ) ) { return compactIri ( ( String ) value . get ( JsonLdConsts . ID ) , true ) ; } return value ; } final Object valueValue = value . get ( JsonLdConsts . VALUE ) ; if ( value . containsKey ( JsonLdConsts . TYPE ) && Obj . equals ( value . get ( JsonLdConsts . TYPE ) , typeMapping ) ) { return valueValue ; } if ( value . containsKey ( JsonLdConsts . LANGUAGE ) ) { if ( Obj . equals ( value . get ( JsonLdConsts . LANGUAGE ) , languageMapping ) || Obj . equals ( value . get ( JsonLdConsts . LANGUAGE ) , this . get ( JsonLdConsts . LANGUAGE ) ) ) { return valueValue ; } } if ( numberMembers == 1 && ( ! ( valueValue instanceof String ) || ! this . containsKey ( JsonLdConsts . LANGUAGE ) || ( termDefinitions . containsKey ( activeProperty ) && getTermDefinition ( activeProperty ) . containsKey ( JsonLdConsts . LANGUAGE ) && languageMapping == null ) ) ) { return valueValue ; } return value ; }
Value Compaction Algorithm

http://json-ld.org/spec/latest/json-ld-api/#value-compaction

@param activeProperty
The Active Property
@param value
The value to compact
@return The compacted value