blob: 669383bac193cff36bdaf651c9ac56a1282caee2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*******************************************************************************
* Copyright (c) 2001, 2007 Oracle Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Oracle Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.common.sets.mapping;
import java.util.Iterator;
import org.eclipse.jst.jsf.common.sets.AxiomaticSet;
import org.eclipse.jst.jsf.common.sets.ConcreteAxiomaticSet;
/**
* Super-class of all ObjectInjectiveSetMapping.
*
* <p><b>Provisional API - subject to change</b></p>
*
* @author cbateman
*
*/
public abstract class AbstractObjectInjectiveSetMapping implements
ObjectInjectiveSetMapping {
/* (non-Javadoc)
* @see org.eclipse.jst.jsf.common.sets.mapping.ObjectInjectiveSetMapping#mapIterator(org.eclipse.jst.jsf.common.sets.AxiomaticSet)
*/
public Iterator mapIterator(final AxiomaticSet set)
{
return new Iterator()
{
final Iterator setIterator = set.iterator();
public boolean hasNext()
{
return setIterator.hasNext();
}
public Object next()
{
return map(setIterator.next());
}
public void remove()
{
throw new UnsupportedOperationException("cannot modify iterator"); //$NON-NLS-1$
}
};
}
/**
* @param element
* @return the result object from the mapping on element
*/
public abstract Object map(Object element);
/* (non-Javadoc)
* @see org.eclipse.jst.jsf.common.sets.mapping.AxiomaticSetMapping#map(org.eclipse.jst.jsf.common.sets.AxiomaticSet)
*/
public final AxiomaticSet map(AxiomaticSet set) {
AxiomaticSet resultSet = new ConcreteAxiomaticSet();
for (final Iterator it = mapIterator(set); it.hasNext();)
{
resultSet.add(it.next());
}
return resultSet;
}
}
|