Skip to main content
summaryrefslogtreecommitdiffstats
blob: f15e9457dc4de4df80ab91139ba02b7f19058e09 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*******************************************************************************
 * Copyright (c) 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.metatype.impl;

import org.eclipse.osgi.util.NLS;

public class Designate {
	public static class Builder {
		String bundle;
		String factoryPid;
		boolean merge;
		ObjectClassDefinitionImpl ocd;
		boolean optional;
		String pid;

		public Builder(ObjectClassDefinitionImpl ocd) {
			if (ocd == null) {
				throw new IllegalArgumentException(NLS.bind(MetaTypeMsg.MISSING_REQUIRED_PARAMETER, "ocd")); //$NON-NLS-1$
			}
			this.ocd = ocd;
		}

		public Designate build() {
			return new Designate(this);
		}

		public Builder bundle(String value) {
			bundle = value;
			return this;
		}

		public Builder factoryPid(String value) {
			factoryPid = value;
			return this;
		}

		public Builder merge(boolean value) {
			merge = value;
			return this;
		}

		public Builder optional(boolean value) {
			optional = value;
			return this;
		}

		public Builder pid(String value) {
			pid = value;
			return this;
		}
	}

	private final String bundle;
	private final String factoryPid;
	private final boolean merge;
	private final ObjectClassDefinitionImpl ocd;
	private final boolean optional;
	private final String pid;

	Designate(Builder b) {
		bundle = b.bundle;
		factoryPid = b.factoryPid;
		merge = b.merge;
		ocd = b.ocd;
		optional = b.optional;
		pid = b.pid;
	}

	public String getBundle() {
		return bundle;
	}

	public String getFactoryPid() {
		return factoryPid;
	}

	public boolean isFactory() {
		return factoryPid != null && factoryPid.length() != 0;
	}

	public boolean isMerge() {
		return merge;
	}

	public ObjectClassDefinitionImpl getObjectClassDefinition() {
		return ocd;
	}

	public boolean isOptional() {
		return optional;
	}

	public String getPid() {
		return pid;
	}
}

Back to the top