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

org.cache2k.configuration.DefaultCustomizationCollection Maven / Gradle / Ivy

Go to download

A light weight and high performance Java caching library. Android and Java 6 compatible. This artifact contains the official API of cache2k.

There is a newer version: 2.6.1.Final
Show newest version
package org.cache2k.configuration;

/*
 * #%L
 * cache2k API
 * %%
 * Copyright (C) 2000 - 2020 headissue GmbH, Munich
 * %%
 * 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.
 * #L%
 */

import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 * Default implementation for a customization collection using a list.
 *
 * 

Rationale: Inserting is a little expansive, since we check whether * an entry is already existing. Since there are usually only a few entries * the list is sufficient. * * @author Jens Wilke */ public final class DefaultCustomizationCollection extends AbstractCollection> implements CustomizationCollection { private Collection> list = new ArrayList>(); @Override public int size() { return list.size(); } @Override public Iterator> iterator() { return list.iterator(); } /** * Adds a customization to the collection. * * @return always {@code true} * @throws IllegalArgumentException if the entry is already existing. */ @Override public boolean add(final CustomizationSupplier entry) { if (list.contains(entry)) { throw new IllegalArgumentException("duplicate entry"); } return list.add(entry); } public String toString() { return getClass().getSimpleName() + list.toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy