App Engine Python SDK version 1.8.4
[gae.git] / java / src / main / com / google / apphosting / utils / config / WebModule.java
blob3c164d7f9c744f6cf629227786f99c8fa817561a
1 package com.google.apphosting.utils.config;
3 import com.google.common.base.StringUtil;
5 import java.io.File;
7 /**
8 * Holder for information for a web module extracted from the module's
9 * on disk application directory.
12 public class WebModule {
13 /**
14 * Default value for a module name.
16 public static final String DEFAULT_MODULE_NAME = "default";
18 private final File applicationDirectory;
19 private final AppEngineWebXml appEngineWebXml;
20 private final File appEngineWebXmlFile;
21 private final WebXml webXml;
22 private final File webXmlFile;
23 private final String contextRoot;
25 /**
26 * Returns the server name specified in {@link #getAppEngineWebXml()} or
27 * {@link #DEFAULT_SERVER_NAME} if none is specified.
29 public static String getModuleName(AppEngineWebXml appEngineWebXml) {
30 return StringUtil.isEmptyOrWhitespace(appEngineWebXml.getModule()) ?
31 "default" : appEngineWebXml.getModule().trim();
34 WebModule(File applicationDirectory, AppEngineWebXml appEngineWebXml, File appEngineWebXmlFile,
35 WebXml webXml, File webXmlFile, String contextRoot) {
36 this.applicationDirectory = applicationDirectory;
37 this.appEngineWebXml = appEngineWebXml;
38 this.appEngineWebXmlFile = appEngineWebXmlFile;
39 this.webXml = webXml;
40 this.webXmlFile = webXmlFile;
41 this.contextRoot = contextRoot;
44 public File getApplicationDirectory() {
45 return applicationDirectory;
48 public AppEngineWebXml getAppEngineWebXml() {
49 return appEngineWebXml;
52 public File getAppEngineWebXmlFile() {
53 return appEngineWebXmlFile;
56 public WebXml getWebXml() {
57 return webXml;
60 public File getWebXmlFile() {
61 return webXmlFile;
64 public String getContextRoot() {
65 return contextRoot;
68 /**
69 * Returns the module name specified in {@link #getAppEngineWebXml()} or
70 * {@link #DEFAULT_MODULE_NAME} if none is specified.
72 public String getModuleName() {
73 return getModuleName(appEngineWebXml);
76 @Override
77 public int hashCode() {
78 final int prime = 31;
79 int result = 1;
80 result = prime * result + ((appEngineWebXml == null) ? 0 : appEngineWebXml.hashCode());
81 result = prime * result + ((appEngineWebXmlFile == null) ? 0 : appEngineWebXmlFile.hashCode());
82 result =
83 prime * result + ((applicationDirectory == null) ? 0 : applicationDirectory.hashCode());
84 result = prime * result + ((contextRoot == null) ? 0 : contextRoot.hashCode());
85 result = prime * result + ((webXml == null) ? 0 : webXml.hashCode());
86 result = prime * result + ((webXmlFile == null) ? 0 : webXmlFile.hashCode());
87 return result;
90 @Override
91 public boolean equals(Object obj) {
92 if (this == obj) {
93 return true;
95 if (obj == null) {
96 return false;
98 if (getClass() != obj.getClass()) {
99 return false;
101 WebModule other = (WebModule) obj;
102 if (appEngineWebXml == null) {
103 if (other.appEngineWebXml != null) {
104 return false;
106 } else if (!appEngineWebXml.equals(other.appEngineWebXml)) {
107 return false;
109 if (appEngineWebXmlFile == null) {
110 if (other.appEngineWebXmlFile != null) {
111 return false;
113 } else if (!appEngineWebXmlFile.equals(other.appEngineWebXmlFile)) {
114 return false;
116 if (applicationDirectory == null) {
117 if (other.applicationDirectory != null) {
118 return false;
120 } else if (!applicationDirectory.equals(other.applicationDirectory)) {
121 return false;
123 if (contextRoot == null) {
124 if (other.contextRoot != null) {
125 return false;
127 } else if (!contextRoot.equals(other.contextRoot)) {
128 return false;
130 if (webXml == null) {
131 if (other.webXml != null) {
132 return false;
134 } else if (!webXml.equals(other.webXml)) {
135 return false;
137 if (webXmlFile == null) {
138 if (other.webXmlFile != null) {
139 return false;
141 } else if (!webXmlFile.equals(other.webXmlFile)) {
142 return false;
144 return true;
147 @Override
148 public String toString() {
149 return "WebModule: applicationDirectory=" + applicationDirectory
150 + " appEngineWebXml=" + appEngineWebXml
151 + " appEngineWebXmlFile=" + appEngineWebXmlFile
152 + " webXml=" + webXml
153 + " webXmlFile=" + webXmlFile
154 + " contextRoot=" + contextRoot;