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

com.yahoo.elide.modelconfig.model.Named Maven / Gradle / Ivy

There is a newer version: 7.1.2
Show newest version
/*
 * Copyright 2020, Yahoo Inc.
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root for terms.
 */
package com.yahoo.elide.modelconfig.model;

import java.io.Serializable;
import java.util.Collection;

public interface Named extends Serializable {
    /**
     * Get the name local to its parent.
     * @return the local name
     */
    String getName();

    /**
     * Get the globally unique name .
     * @return the global name
     */
    default String getGlobalName() {
        return getName();
    }

    /**
     * Checks if the collection has an object with given name.
     * @param collection of object with name property
     * @param name to search for in given collection
     * @return true if the collection has an object with given name.
     */
    default boolean hasName(Collection collection, String name) {
        return collection
                        .stream()
                        .map(Named::getGlobalName)
                        .anyMatch(name::equals);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy