All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.helger.lesscommons.homoglyphs.HomoglyphSearchResult Maven / Gradle / Ivy

/*
 * Copyright (C) 2014-2024 Philip Helger (www.helger.com)
 * philip[at]helger[dot]com
 *
 * 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.helger.lesscommons.homoglyphs;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;

import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.Nonempty;
import com.helger.commons.string.ToStringGenerator;

/**
 * Search result of a homoglyph search.
 *
 * @author Rob Dawson
 * @author Philip Helger
 */
@Immutable
public class HomoglyphSearchResult
{
  private final int m_nIndex;
  private final String m_sMatch;
  private final String m_sWord;

  public HomoglyphSearchResult (@Nonnegative final int nIndex,
                                @Nonnull @Nonempty final String sMatch,
                                @Nonnull @Nonempty final String sWord)
  {
    ValueEnforcer.isGE0 (nIndex, "Index");
    ValueEnforcer.notEmpty (sMatch, "Match");
    ValueEnforcer.notEmpty (sWord, "Word");
    m_nIndex = nIndex;
    m_sMatch = sMatch;
    m_sWord = sWord;
  }

  @Nonnegative
  public int getIndex ()
  {
    return m_nIndex;
  }

  @Nonnull
  @Nonempty
  public String getMatch ()
  {
    return m_sMatch;
  }

  @Nonnull
  @Nonempty
  public String getWord ()
  {
    return m_sWord;
  }

  @Nonnull
  public String getAsString ()
  {
    return "'" + m_sMatch + "' at position " + m_nIndex + " matches '" + m_sWord + "'";
  }

  @Override
  public String toString ()
  {
    return new ToStringGenerator (this).append ("Index", m_nIndex).append ("Match", m_sMatch).append ("Word", m_sWord).getToString ();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy