/*
 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
 *
 * 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 org.gbif.api.model;

import java.util.UUID;

/**
 * Encapsulate a challenge code.
 */
public class ChallengeCode {
  private Integer key;
  private UUID code;

  public static ChallengeCode newRandom() {
    ChallengeCode challengeCode = new ChallengeCode();
    challengeCode.setCode(UUID.randomUUID());
    return challengeCode;
  }

  public Integer getKey() {
    return key;
  }

  public void setKey(Integer key) {
    this.key = key;
  }

  public UUID getCode() {
    return code;
  }

  public void setCode(UUID code) {
    this.code = code;
  }
}

@@ -653,16 +653,47 @@
 model;%0A%0A
+import java.util.StringJoiner;%0A
 import j
@@ -707,16 +707,16 @@
 l.UUID;%0A
-
 %0A/**%0A * 
@@ -778,16 +778,17 @@
 eCode %7B%0A
+%0A
   privat
@@ -822,16 +822,99 @@
 ID code;
+%0A  // additional data (may be an email address or something)%0A  private String data;
 %0A%0A  publ
@@ -1075,32 +1075,198 @@
 lengeCode;%0A  %7D%0A%0A
+  public static ChallengeCode newRandom(String data) %7B%0A    ChallengeCode challengeCode = newRandom();%0A    challengeCode.setData(data);%0A    return challengeCode;%0A  %7D%0A%0A
   public Integer
@@ -1438,24 +1438,24 @@
 UID code) %7B%0A
-
     this.cod
@@ -1467,11 +1467,366 @@
 ode;%0A  %7D
+%0A%0A  public String getData() %7B%0A    return data;%0A  %7D%0A%0A  public void setData(String data) %7B%0A    this.data = data;%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    return new StringJoiner(%22, %22, ChallengeCode.class.getSimpleName() + %22%5B%22, %22%5D%22)%0A        .add(%22key=%22 + key)%0A        .add(%22code=%22 + code)%0A        .add(%22data='%22 + data + %22'%22)%0A        .toString();%0A  %7D
 %0A%7D%0A

Add additional field to ChallengeCode