1 /*
2 * Copyright 2018 Andrew Rucker Jones.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.opencsv.bean;
17
18 import java.util.Locale;
19
20 /**
21 * Defines the basic functionality necessary for using a many-to-one mapping
22 * between columns of a CSV file and bean fields.
23 * Such a mapping requires a method of matching multiple fields. This method
24 * will require data to initialize itself. Such a mapping also requires a key to
25 * index the {@link BeanField} that is to be provided for a match.
26 *
27 * @param <I> The initializer type used to build the many-to-one mapping
28 * @param <K> The type of the key used for indexing
29 * @param <T> The type of the bean being converted
30 *
31 * @author Andrew Rucker Jones
32 * @since 4.2
33 */
34 public interface ComplexFieldMapEntry<I, K extends Comparable<K>, T> {
35
36 /**
37 * Determines whether or not the given key is contained in this entry.
38 *
39 * @param key The key to be located
40 * @return Whether {@code key} is represented by this entry
41 */
42 boolean contains(K key);
43
44 /**
45 * @return The {@link BeanField} to which this entry maps
46 */
47 BeanField<T, K> getBeanField();
48
49 /**
50 * Returns the information used to initialize this entry.
51 * This information is not guaranteed to be exactly the same as the original
52 * value, but is functionally equivalent.
53 *
54 * @return The original information used to initialize this mapping entry
55 */
56 I getInitializer();
57
58 /**
59 * Sets the locale to be used for error messages.
60 *
61 * @param errorLocale The locale to be used for error messages
62 */
63 void setErrorLocale(Locale errorLocale);
64 }