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

ga.sdk.sdk-generate-entity-models-maven-plugin.12.60.16.source-code.Lists.vm Maven / Gradle / Ivy

The newest version!
############################################################################
## Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##   http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
############################################################################
package com.hpe.adm.nga.sdk.enums;

import com.hpe.adm.nga.sdk.model.EntityModel;
import com.hpe.adm.nga.sdk.model.StringFieldModel;
import java.util.Arrays;

/**
 * Generated class - do not edit!
 */
public final class Lists {

#foreach($listItemsSet in ${listNodes.entrySet()})
    #set($listItems = $listItemsSet.getValue())
    #set($rootModel = $listItems.get(0))
    #set($rootModelName = ${rootModel[0]})
    public enum $rootModelName {
        #foreach($listModel in $listItems)#if(!$foreach.first)
        #if($foreach.count > 2), #end${listModel[0]}("${listModel[1]}")#end
        #end;

        public static final String ROOT_ID = "${rootModel[1]}";

        private final String id;

        $rootModelName(final String id) {
            this.id = id;
        }

        public final String getId() {
            return id;
        }

        public static $rootModelName getListNodeFromId(String id) {
            return Arrays.stream(${rootModelName}.values()).filter(listNode -> listNode.id.equals(id)).findFirst().orElse(null);
        }

        public final EntityModel getAsEntityModel() {
            final EntityModel entityModel = new EntityModel();
            entityModel.setValue(new StringFieldModel("id", id));
            entityModel.setValue(new StringFieldModel("type", "list_node"));
            return entityModel;
        }

        public static $rootModelName getFromEntityModel(final EntityModel entityModel) {
            return ${rootModelName}.getListNodeFromId(entityModel.getId());
        }
    }
#end
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy