001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.model.common;
017
018import java.util.Objects;
019import java.util.StringJoiner;
020
021/**
022 * Allows for encapsulating a verbatim and an interpreted value of any type.
023 */
024@Deprecated
025public class InterpretedField<V, I> {
026
027  private V verbatim;
028  private I interpreted;
029
030  public InterpretedField() {
031  }
032
033  public InterpretedField(V verbatim, I interpreted) {
034    this.verbatim = verbatim;
035    this.interpreted = interpreted;
036  }
037
038  public I getInterpreted() {
039    return interpreted;
040  }
041
042  public void setInterpreted(I interpreted) {
043    this.interpreted = interpreted;
044  }
045
046  public V getVerbatim() {
047    return verbatim;
048  }
049
050  public void setVerbatim(V verbatim) {
051    this.verbatim = verbatim;
052  }
053
054  @Override
055  public boolean equals(Object o) {
056    if (this == o) {
057      return true;
058    }
059    if (o == null || getClass() != o.getClass()) {
060      return false;
061    }
062    InterpretedField<?, ?> that = (InterpretedField<?, ?>) o;
063    return Objects.equals(verbatim, that.verbatim) &&
064      Objects.equals(interpreted, that.interpreted);
065  }
066
067  @Override
068  public int hashCode() {
069    return Objects.hash(verbatim, interpreted);
070  }
071
072  @Override
073  public String toString() {
074    return new StringJoiner(", ", InterpretedField.class.getSimpleName() + "[", "]")
075      .add("verbatim=" + verbatim)
076      .add("interpreted=" + interpreted)
077      .toString();
078  }
079}