1
2
3
4
5 package org.apache.maven.toolchain.model;
6
7 import java.io.Serializable;
8 import java.util.AbstractList;
9 import java.util.Collections;
10 import java.util.HashMap;
11 import java.util.List;
12 import java.util.Map;
13 import java.util.Objects;
14 import java.util.Properties;
15 import java.util.stream.Collectors;
16 import java.util.stream.Stream;
17 import org.apache.maven.api.annotations.Generated;
18 import org.apache.maven.api.annotations.Nonnull;
19 import org.codehaus.plexus.util.xml.Xpp3Dom;
20
21 @Generated
22 public class ToolchainModel
23 extends TrackableBase
24 implements Serializable, Cloneable
25 {
26
27 public ToolchainModel() {
28 this(org.apache.maven.api.toolchain.ToolchainModel.newInstance());
29 }
30
31 public ToolchainModel(org.apache.maven.api.toolchain.ToolchainModel delegate) {
32 this(delegate, null);
33 }
34
35 public ToolchainModel(org.apache.maven.api.toolchain.ToolchainModel delegate, BaseObject parent) {
36 super(delegate, parent);
37 }
38
39 public ToolchainModel clone(){
40 return new ToolchainModel(getDelegate());
41 }
42
43 @Override
44 public org.apache.maven.api.toolchain.ToolchainModel getDelegate() {
45 return (org.apache.maven.api.toolchain.ToolchainModel) super.getDelegate();
46 }
47
48 @Override
49 public boolean equals(Object o) {
50 if (this == o) {
51 return true;
52 }
53 if (o == null || !(o instanceof ToolchainModel)) {
54 return false;
55 }
56 ToolchainModel that = (ToolchainModel) o;
57 return Objects.equals(this.delegate, that.delegate);
58 }
59
60 @Override
61 public int hashCode() {
62 return getDelegate().hashCode();
63 }
64
65 public String getType() {
66 return getDelegate().getType();
67 }
68
69 public void setType(String type) {
70 if (!Objects.equals(type, getType())) {
71 update(getDelegate().withType(type));
72 }
73 }
74
75 @Nonnull
76 public Properties getProvides() {
77 return new WrapperProperties(() -> getDelegate().getProvides(), this::setProvides);
78 }
79
80 public void setProvides(Properties provides) {
81 Map<String, String> map = provides.entrySet().stream()
82 .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()));
83 if (!Objects.equals(map, getDelegate().getProvides())) {
84 update(getDelegate().withProvides(map));
85 }
86 }
87
88 public void addProvide(String key, String value) {
89 getProvides().put(key, value);
90 }
91
92 public Object getConfiguration() {
93 return getDelegate().getConfiguration() != null ? new Xpp3Dom(getDelegate().getConfiguration(), this::replace) : null;
94 }
95
96 public void setConfiguration(Object configuration) {
97 if (configuration instanceof Xpp3Dom) {
98 if (!Objects.equals(((Xpp3Dom) configuration).getDom(), getDelegate().getConfiguration())) {
99 update(getDelegate().withConfiguration(((Xpp3Dom) configuration).getDom()));
100 ((Xpp3Dom) configuration).setChildrenTracking(this::replace);
101 }
102 } else if (configuration == null) {
103 if (getDelegate().getConfiguration() != null) {
104 update(getDelegate().withConfiguration(null));
105 }
106 } else {
107 throw new IllegalArgumentException("Expected an Xpp3Dom object but received a " + configuration.getClass() + ": " + configuration);
108 }
109 }
110
111 protected boolean replace(Object oldDelegate, Object newDelegate) {
112 if (super.replace(oldDelegate, newDelegate)) {
113 return true;
114 }
115 if (getDelegate().getConfiguration() == oldDelegate) {
116 update(getDelegate().withConfiguration((org.apache.maven.api.xml.XmlNode) newDelegate));
117 }
118 return false;
119 }
120
121 public static List<org.apache.maven.api.toolchain.ToolchainModel> toolchainModelToApiV4(List<ToolchainModel> list) {
122 return list != null ? new WrapperList<>(list, ToolchainModel::getDelegate, ToolchainModel::new) : null;
123 }
124
125 public static List<ToolchainModel> toolchainModelToApiV3(List<org.apache.maven.api.toolchain.ToolchainModel> list) {
126 return list != null ? new WrapperList<>(list, ToolchainModel::new, ToolchainModel::getDelegate) : null;
127 }
128
129 }