01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.ws.policy.builder.jaxb;
19:
20: import javax.xml.namespace.QName;
21:
22: import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
23: import org.apache.neethi.Assertion;
24: import org.apache.neethi.PolicyComponent;
25:
26: /**
27: *
28: */
29: public class JaxbAssertion<T> extends PrimitiveAssertion {
30:
31: private T data;
32:
33: public JaxbAssertion() {
34: }
35:
36: public JaxbAssertion(QName qn, boolean optional) {
37: super (qn, optional);
38: }
39:
40: @Override
41: @SuppressWarnings("unchecked")
42: public boolean equal(PolicyComponent policyComponent) {
43: if (!super .equal(policyComponent)) {
44: return false;
45: }
46: JaxbAssertion<T> a = (JaxbAssertion<T>) policyComponent;
47: return data.equals(a.getData());
48: }
49:
50: public void setData(T d) {
51: data = d;
52: }
53:
54: public T getData() {
55: return data;
56: }
57:
58: protected Assertion cloneMandatory() {
59: JaxbAssertion<T> a = new JaxbAssertion<T>(getName(), false);
60: a.setData(data);
61: return a;
62: }
63:
64: @SuppressWarnings("unchecked")
65: public static <T> JaxbAssertion<T> cast(Assertion a) {
66: return (JaxbAssertion<T>) a;
67: }
68:
69: @SuppressWarnings("unchecked")
70: public static <T> JaxbAssertion<T> cast(Assertion a, Class<T> type) {
71: return (JaxbAssertion<T>) a;
72: }
73:
74: }
|