001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2022–2023 microBean™.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
006 * the License.  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 distributed under the License is distributed on
011 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
012 * specific language governing permissions and limitations under the License.
013 */
014package org.microbean.invoke;
015
016import java.util.Optional;
017
018/**
019 * An interface whose implementations can return a {@link CharSequence} for content-based hashing.
020 *
021 * @author <a href="https://about.me/lairdnelson" target="_parent">Laird Nelson</a>
022 */
023@FunctionalInterface
024public interface ContentHashable {
025
026  /**
027   * Returns an {@link Optional} whose content is a {@link CharSequence} representing a "content hashable" view of the
028   * implementation.
029   *
030   * <p>If the returned {@link Optional} {@linkplain Optional#isEmpty() is empty}, no "content hashable" view of the
031   * implementation exists, and content hashing of this implementation may lead to undefined behavior.</p>
032   *
033   * <p>Implementations of this method must produce a determinate value, or undefined behavior will result.</p>
034   *
035   * @return an {@link Optional} whose content is a {@link CharSequence} representing a "content hashable" view of the
036   * implementation
037   */
038  public Optional<? extends CharSequence> contentHashInput();
039
040}