/*******************************************************************************
 * MIT License
 *
 * Copyright (c) Igor Conrado Alves de Lima <igorcadelima@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *******************************************************************************/
package gavel.impl.sanction;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import gavel.api.sanction.SanctionOutcome;
import gavel.impl.common.Enums;
import gavel.impl.common.DefaultUuid;

/**
 * Static utility methods pertaining to {@link SanctionOutcome} instances.
 * 
 * @author igorcadelima
 *
 */
public final class SanctionOutcomes {
  private SanctionOutcomes() {}

  /**
   * Return a new {@link SanctionOutcome} instance whose string representation is the given
   * {@code in}.
   * 
   * @param in string to be parsed
   * @return sanction outcome represented by the string argument if parsing succeeds; {@code null}
   *         otherwise
   * @throws IllegalArgumentException if string does not contain a parsable sanction outcome
   * @throws NullPointerException if string is {@code null}
   */
  public static SanctionOutcome tryParse(String norm) {
    Pattern pattern = Pattern.compile("sanction_outcome\\\\s*(" + "\\s*id\\s*\\(\\s*(\\w+)\\s*\\),"
        + "\\s*time\\s*\\(\\s*(\\w+)\\s*\\)," + "\\s*application_id\\s*\\(\\s*(\\w+)\\s*\\),"
        + "\\s*controller_id\\s*\\(\\s*(\\w+)\\s*\\)," + "\\s*efficacy\\s*\\(\\s*(\\w+)\\s*\\)\\)");
    Matcher matcher = pattern.matcher(norm);
    matcher.find();
    if (matcher.matches()) {
      return DefaultSanctionOutcome.builder()
                                .time(Long.valueOf(matcher.group(2)))
                                .applicationId(DefaultUuid.parse(matcher.group(3)))
                                .controllerId(matcher.group(4))
                                .efficacy(
                                    Enums.lookup(DiscreteSanctionEfficacy.class, matcher.group(5)))
                                .build();
    }
    return null;
  }
}

@@ -1703,16 +1703,177 @@
 s() %7B%7D%0A%0A
+  /** Returns the name of the structure used to represent a sanction outcome. */%0A  public static String getStructureName() %7B%0A    return %22sanction_outcome%22;%0A  %7D%0A%0A
   /**%0A  
@@ -2824,16 +2824,19 @@
         
+   
 .time(Lo
@@ -2861,24 +2861,27 @@
 .group(2)))%0A
+   
             
@@ -2984,16 +2984,19 @@
         
+   
 .control
@@ -3019,16 +3019,19 @@
 oup(4))%0A
+   
         
@@ -3068,45 +3068,8 @@
 acy(
-%0A                                    
 Enum
@@ -3108,16 +3108,55 @@
 y.class,
+%0A                                      
  matcher
@@ -3163,24 +3163,27 @@
 .group(5)))%0A
+   
             

Add #getStructureName()