/*
 * Copyright (c) 2012 by The Author(s)
 *
 * 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.github.ferstl.maven.pomenforcers;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;

import com.github.ferstl.maven.pomenforcers.priority.PriorityComparator;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.collect.Maps;



public enum PomSection {
  MODEL_VERSION("modelVersion"),
  PREREQUISITES("prerequisites"),
  PARENT("parent"),
  GROUP_ID("groupId"),
  ARTIFACT_ID("artifactId"),
  VERSION("version"),
  PACKAGING("packaging"),
  NAME("name"),
  DESCRIPTION("description"),
  URL("url"),
  LICENSES("licenses"),
  ORGANIZATION("organization"),
  INCEPTION_YEAR("inceptionYear"),
  CI_MANAGEMENT("ciManagement"),
  MAILING_LISTS("mailingLists"),
  ISSUE_MANAGEMENT("issueManagement"),
  DEVELOPERS("developers"),
  CONTRIBUTORS("contributors"),
  SCM("scm"),
  REPOSITORIES("repositories"),
  PLUGIN_REPOSITORIES("pluginRepositories"),
  DISTRIBUTION_MANAGEMENT("distributionManagement"),
  MODULES("modules"),
  PROPERTIES("properties"),
  DEPENDENCY_MANAGEMENT("dependencyManagement"),
  DEPENDENCIES("dependencies"),
  BUILD("build"),
  PROFILES("profiles"),
  REPORTING("reporting"),
  REPORTS("reports");

  private static final Map<String, PomSection> pomSectionMap;

  static {
    pomSectionMap = Maps.newHashMap();
    for (PomSection pomSection : values()) {
      pomSectionMap.put(pomSection.getSectionName(), pomSection);
    }
  }

  public static PomSection getBySectionName(String sectionName) {
    if (sectionName == null) {
      throw new NullPointerException("Section name is null.");
    }

    PomSection value = pomSectionMap.get(sectionName);
    if (value == null) {
      throw new IllegalArgumentException("POM section " + sectionName + " does not exist.");
    }
    return value;
  }

  private final String sectionName;

  private PomSection(String sectionName) {
    this.sectionName = sectionName;
  }

  public String getSectionName() {
    return this.sectionName;
  }

  public static Comparator<PomSection> createPriorityComparator(
      Collection<PomSection> priorityCollection) {
    Function<PomSection, PomSection> identity = Functions.identity();
      return new PriorityComparator<>(priorityCollection, identity);
  }

}

@@ -824,49 +824,8 @@
 r;%0D%0A
-import com.google.common.base.Function;%0D%0A
 impo
@@ -2723,24 +2723,16 @@
 parator(
-%0D%0A      
 Collecti
@@ -2773,81 +2773,8 @@
  %7B%0D%0A
-    Function%3CPomSection, PomSection%3E identity = Functions.identity();%0D%0A  
     
@@ -2829,16 +2829,38 @@
 on, 
+Functions.%3CPomSection%3E
 identity
 );%0D%0A
@@ -2855,16 +2855,18 @@
 identity
+()
 );%0D%0A  %7D%0D

fix formatting