class MongoDbVarNameAdapter extends VarNameAdapter {

    @Override
    public String getVariableName(String name) throws InvalidParseOperationException {
        if (name.charAt(0) == ParserTokens.DEFAULT_HASH_PREFIX_CHAR) {
            // Check on prefix (preceding '.')
            int pos = name.indexOf('.');
            final String realname;
            final String extension;
            if (pos > 1) {
                realname = name.substring(1, pos);
                extension = name.substring(pos);
            } else {
                realname = name.substring(1);
                extension = "";
            }
            try {
                final PROJECTIONARGS proj = ParserTokens.PROJECTIONARGS.parse(realname);
                switch (proj) {
                    case DUA:
                        // Valid for Unit
                        return Unit.APPRAISALRULES + extension;
                    case FORMAT:
                        // Valid for OG
                        return ObjectGroup.OBJECTFORMAT;
                    case ID:
                        // Valid for Unit and OG
                        return VitamDocument.ID;
                    case QUALIFIERS:
                        // Valid for OG
                        return MetadataDocument.QUALIFIERS + extension;
                    case NBUNITS:
                        // Valid for Unit
                        return Unit.NBCHILD;
                    case NBOBJECTS:
                        // Valid for OG
                        return ObjectGroup.NBCHILD;
                    case SIZE:
                        // Valid for OG
                        return ObjectGroup.OBJECTSIZE;
                    case TYPE:
                        // Valid for Unit and OG
                        return MetadataDocument.TYPE;
                    case TENANT:
                        // Valid for Unit and OG
                        return VitamDocument.TENANT_ID;
                    case OBJECT:
                        // Valid for Unit
                        return MetadataDocument.OG;
                    case UNITUPS:
                        // Valid for Unit and OG
                        return MetadataDocument.UP;
                    case MIN:
                        // Valid for Unit
                        return Unit.MINDEPTH;
                    case MAX:
                        // Valid for Unit
                        return Unit.MAXDEPTH;
                    case ALLUNITUPS:
                        // Valid for Unit
                        return Unit.UNITUPS;
                    case UNITTYPE:
                        // Valid for Unit
                        return Unit.UNIT_TYPE;
                    case MANAGEMENT:
                        // Valid for Unit
                        return Unit.MANAGEMENT + extension;
                    case OPERATIONS:
                        // Valid for Unit and OG
                        return MetadataDocument.OPS;
                    case OPI:
                        // Valid for Unit and OG
                        return MetadataDocument.OPI;
                    case ORIGINATING_AGENCY:
                        // Valid for Unit and OG
                        return MetadataDocument.ORIGINATING_AGENCY;
                    case ORIGINATING_AGENCIES:
                        // Valid for Unit and OG
                        return MetadataDocument.ORIGINATING_AGENCIES;
                    case VERSION:
                        // Valid for Unit and OG (And for VitamDocument items)
                        return MetadataDocument.VERSION;
                    case ATOMIC_VERSION:
                        // Valid for Unit and OG (And for VitamDocument items)
                        return MetadataDocument.ATOMIC_VERSION;
                    case STORAGE:
                        // Valid for OG an Unit
                        return ObjectGroup.STORAGE + extension;
                    case SCORE:
                        return VitamDocument.SCORE;
                    case UDS:
                        return Unit.UNITDEPTHS;
                    case GRAPH:
                        return Unit.GRAPH;
                    case ELIMINATION:
                        return Unit.ELIMINATION + extension;
                    case COMPUTEDINHERITEDRULES:
                        return Unit.COMPUTED_INHERITED_RULES + extension;
                    case VALIDCOMPUTEDINHERITEDRULES:
                        return Unit.VALID_COMPUTED_INHERITED_RULES;
                    case OPTS:
                        return Unit.OPERATION_TRANSFERS;
                    case GRAPH_LAST_PERISTED_DATE:
                        return MetadataDocument.GRAPH_LAST_PERSISTED_DATE;
                    case PARENT_ORIGINATING_AGENCIES:
                        return Unit.PARENT_ORIGINATING_AGENCIES;
                    case HISTORY:
                        return Unit.HISTORY + extension;
                    case SEDAVERSION:
                        return VitamDocument.SEDAVERSION;
                    case IMPLEMENTATIONVERSION:
                        return VitamDocument.IMPLEMENTATIONVERSION;
                    case ALL:
                    default:
                        break;
                }

            } catch (final IllegalArgumentException e) {
                throw new InvalidParseOperationException("Name: " + name, e);
            }
        }
        return null;
    }

    public  MongoDbVarNameAdapter();

}