it.tidalwave.mobile.rss.EntityWithProperties Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - open source birdwatching
* ==========================================
*
* Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
* http://bluebill.tidalwave.it/mobile/
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* $Id: EntityWithProperties.java,v c94a06e77b11 2010/07/04 11:51:33 fabrizio $
*
**********************************************************************************************************************/
package it.tidalwave.mobile.rss;
import it.tidalwave.util.NotFoundException;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import it.tidalwave.util.Id;
import it.tidalwave.util.Key;
import it.tidalwave.util.TypeSafeMultiMap;
import it.tidalwave.util.TypeSafeHashMultiMap;
import it.tidalwave.mobile.media.Media;
import it.tidalwave.util.As;
import it.tidalwave.util.TypeSafeHashMap;
import it.tidalwave.util.TypeSafeMap;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id: $
*
**********************************************************************************************************************/
@Immutable
public class EntityWithProperties implements As, TypeSafeMap
{
private final TypeSafeMap map;
@Nonnull
private final Id id;
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public EntityWithProperties (final @Nonnull Id id)
{
this(id, Collections., Object>emptyMap());
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected EntityWithProperties (final @Nonnull Id id, final @Nonnull Map, Object> map)
{
this.id = id;
this.map = new TypeSafeHashMap(map);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public Id getId()
{
return id;
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public T get (final @Nonnull Key key)
throws NotFoundException
{
return map.get(key);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public boolean containsKey (final @Nonnull Key> item)
{
return map.containsKey(item);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public Set> getKeys()
{
return map.getKeys();
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnegative
public int getSize()
{
return map.getSize();
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public Iterator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy