|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 PANTHEON.tech, s.r.o. and others. All rights reserved. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made available under the |
| 5 | + * terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 6 | + * and is available at http://www.eclipse.org/legal/epl-v10.html |
| 7 | + */ |
| 8 | +package io.lighty.modules.northbound.netty.restconf.community.impl.config; |
| 9 | + |
| 10 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 11 | +import java.net.InetAddress; |
| 12 | +import java.util.Objects; |
| 13 | +import org.opendaylight.mdsal.dom.api.DOMActionService; |
| 14 | +import org.opendaylight.mdsal.dom.api.DOMDataBroker; |
| 15 | +import org.opendaylight.mdsal.dom.api.DOMMountPointService; |
| 16 | +import org.opendaylight.mdsal.dom.api.DOMNotificationService; |
| 17 | +import org.opendaylight.mdsal.dom.api.DOMRpcService; |
| 18 | +import org.opendaylight.mdsal.dom.api.DOMSchemaService; |
| 19 | + |
| 20 | +public class NettyRestConfConfiguration { |
| 21 | + |
| 22 | + @JsonIgnore |
| 23 | + private DOMDataBroker domDataBroker; |
| 24 | + @JsonIgnore |
| 25 | + private DOMSchemaService schemaService; |
| 26 | + @JsonIgnore |
| 27 | + private DOMRpcService domRpcService; |
| 28 | + @JsonIgnore |
| 29 | + private DOMActionService domActionService; |
| 30 | + @JsonIgnore |
| 31 | + private DOMNotificationService domNotificationService; |
| 32 | + @JsonIgnore |
| 33 | + private DOMMountPointService domMountPointService; |
| 34 | + |
| 35 | + private InetAddress inetAddress = InetAddress.getLoopbackAddress(); |
| 36 | + private int httpPort = 8888; |
| 37 | + private String restconfServletContextPath = "restconf"; |
| 38 | + |
| 39 | + public NettyRestConfConfiguration() { |
| 40 | + } |
| 41 | + |
| 42 | + public NettyRestConfConfiguration(final NettyRestConfConfiguration restConfConfiguration) { |
| 43 | + this.inetAddress = restConfConfiguration.getInetAddress(); |
| 44 | + this.httpPort = restConfConfiguration.getHttpPort(); |
| 45 | + this.restconfServletContextPath = restConfConfiguration.getRestconfServletContextPath(); |
| 46 | + this.domDataBroker = restConfConfiguration.getDomDataBroker(); |
| 47 | + this.schemaService = restConfConfiguration.getSchemaService(); |
| 48 | + this.domRpcService = restConfConfiguration.getDomRpcService(); |
| 49 | + this.domActionService = restConfConfiguration.getDomActionService(); |
| 50 | + this.domNotificationService = restConfConfiguration.getDomNotificationService(); |
| 51 | + this.domMountPointService = restConfConfiguration.getDomMountPointService(); |
| 52 | + } |
| 53 | + |
| 54 | + public NettyRestConfConfiguration(final DOMDataBroker domDataBroker, final DOMSchemaService schemaService, |
| 55 | + final DOMRpcService domRpcService, final DOMActionService domActionService, |
| 56 | + final DOMNotificationService domNotificationService, final DOMMountPointService domMountPointService) { |
| 57 | + this.domDataBroker = domDataBroker; |
| 58 | + this.schemaService = schemaService; |
| 59 | + this.domRpcService = domRpcService; |
| 60 | + this.domActionService = domActionService; |
| 61 | + this.domNotificationService = domNotificationService; |
| 62 | + this.domMountPointService = domMountPointService; |
| 63 | + } |
| 64 | + |
| 65 | + public InetAddress getInetAddress() { |
| 66 | + return this.inetAddress; |
| 67 | + } |
| 68 | + |
| 69 | + public void setInetAddress(final InetAddress inetAddress) { |
| 70 | + this.inetAddress = inetAddress; |
| 71 | + } |
| 72 | + |
| 73 | + public DOMDataBroker getDomDataBroker() { |
| 74 | + return this.domDataBroker; |
| 75 | + } |
| 76 | + |
| 77 | + public void setDomDataBroker(final DOMDataBroker domDataBroker) { |
| 78 | + this.domDataBroker = domDataBroker; |
| 79 | + } |
| 80 | + |
| 81 | + public DOMSchemaService getSchemaService() { |
| 82 | + return this.schemaService; |
| 83 | + } |
| 84 | + |
| 85 | + public void setSchemaService(final DOMSchemaService schemaService) { |
| 86 | + this.schemaService = schemaService; |
| 87 | + } |
| 88 | + |
| 89 | + public DOMRpcService getDomRpcService() { |
| 90 | + return this.domRpcService; |
| 91 | + } |
| 92 | + |
| 93 | + public void setDomRpcService(final DOMRpcService domRpcService) { |
| 94 | + this.domRpcService = domRpcService; |
| 95 | + } |
| 96 | + |
| 97 | + public DOMActionService getDomActionService() { |
| 98 | + return this.domActionService; |
| 99 | + } |
| 100 | + |
| 101 | + public void setDomActionService(final DOMActionService domActionService) { |
| 102 | + this.domActionService = domActionService; |
| 103 | + } |
| 104 | + |
| 105 | + public DOMNotificationService getDomNotificationService() { |
| 106 | + return this.domNotificationService; |
| 107 | + } |
| 108 | + |
| 109 | + public void setDomNotificationService(final DOMNotificationService domNotificationService) { |
| 110 | + this.domNotificationService = domNotificationService; |
| 111 | + } |
| 112 | + |
| 113 | + public DOMMountPointService getDomMountPointService() { |
| 114 | + return this.domMountPointService; |
| 115 | + } |
| 116 | + |
| 117 | + public void setDomMountPointService(final DOMMountPointService domMountPointService) { |
| 118 | + this.domMountPointService = domMountPointService; |
| 119 | + } |
| 120 | + |
| 121 | + public int getHttpPort() { |
| 122 | + return this.httpPort; |
| 123 | + } |
| 124 | + |
| 125 | + public void setHttpPort(final int httpPort) { |
| 126 | + this.httpPort = httpPort; |
| 127 | + } |
| 128 | + |
| 129 | + public String getRestconfServletContextPath() { |
| 130 | + return restconfServletContextPath; |
| 131 | + } |
| 132 | + |
| 133 | + public void setRestconfServletContextPath(final String restconfServletContextPath) { |
| 134 | + this.restconfServletContextPath = restconfServletContextPath.startsWith("/") |
| 135 | + ? restconfServletContextPath.substring(1) : restconfServletContextPath; |
| 136 | + } |
| 137 | + |
| 138 | + @Override |
| 139 | + public boolean equals(final Object obj) { |
| 140 | + if (this == obj) { |
| 141 | + return true; |
| 142 | + } |
| 143 | + if (obj == null || getClass() != obj.getClass()) { |
| 144 | + return false; |
| 145 | + } |
| 146 | + NettyRestConfConfiguration that = (NettyRestConfConfiguration) obj; |
| 147 | + return httpPort == that.httpPort |
| 148 | + && Objects.equals(domDataBroker, that.domDataBroker) |
| 149 | + && Objects.equals(schemaService, that.schemaService) |
| 150 | + && Objects.equals(domRpcService, that.domRpcService) |
| 151 | + && Objects.equals(domActionService, that.domActionService) |
| 152 | + && Objects.equals(domNotificationService, that.domNotificationService) |
| 153 | + && Objects.equals(domMountPointService, that.domMountPointService) |
| 154 | + && Objects.equals(inetAddress, that.inetAddress) |
| 155 | + && Objects.equals(restconfServletContextPath, that.restconfServletContextPath); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + public int hashCode() { |
| 160 | + return Objects.hash(domDataBroker, schemaService, domRpcService, domActionService, domNotificationService, |
| 161 | + domMountPointService, inetAddress, httpPort, restconfServletContextPath); |
| 162 | + } |
| 163 | + |
| 164 | +} |
0 commit comments