public LocationLevel createLocationLevel(String locationName, String locationLevelName) {
    LocationLevel locationLevel = null;
    if (StringUtils.isNotEmpty(locationName) && StringUtils.isNotEmpty(locationLevelName)) {
      String[] locations = locationName.split("/");
      String[] locationLevels = locationLevelName.split("/");
      String locName = "";
      String levelName = "";
      if (locations.length > 0) {
        locName = locations[0];
        levelName = locationLevels[0];
        if (locationName.contains("/")) {
          locationName = locationName.replaceFirst(locations[0] + "/", "");
        } else {
          locationName = locationName.replace(locations[0], "");
        }

        if (locationLevelName.contains("/")) {
          locationLevelName = locationLevelName.replaceFirst(locationLevels[0] + "/", "");
        } else {
          locationLevelName = locationLevelName.replace(locationLevels[0], "");
        }
        if (locName != null && locations.length != 0) {
          locationLevel = new LocationLevel();
          locationLevel.setLevel(levelName);
          locationLevel.setName(locName);
          locationLevel.setLocationLevel(createLocationLevel(locationName, locationLevelName));
        }
      }
    }
    return locationLevel;
  }
Example #2
0
 public LocationLevel getNext() {
   return this.ordinal() < LocationLevel.values().length - 1
       ? LocationLevel.values()[this.ordinal() + 1]
       : null;
 }