Merge branch 'master' of ../controller
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / ProductAwareBuilder.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.concepts;
9
10 /**
11  * An extension of the {@link Builder} concept which allows an implementation
12  * of this interface to be used in collections instead of the product. Given
13  * the mutable nature of Builders, this has to be done very carefully.
14  *
15  * @param <P> Product type
16  */
17 public interface ProductAwareBuilder<P> extends Builder<P> {
18     /**
19      * Return the hash code of the product. This has to be equivalent
20      * of calling {@link #build()}.{@link Object#hashCode()}.
21      *
22      * @return the hash code of the product.
23      */
24     int productHashCode();
25
26     /**
27      * Check whether an instance of the product that would be created
28      * by the builder is equal to an existing instance. This has to
29      * be equivalent of calling {@link #build()}.{@link Object#equals(Object)}.
30      *
31      * @param product Product instance
32      * @return Return true if the product is equal to the would-be
33      *         product of the builder.
34      */
35     boolean productEquals(Object product);
36 }