LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / reportbuilder / java / org / libreoffice / report / pentaho / styles / StyleMapperKey.java
blobedf6cb7c8df25d3f75d371b4ff58d18132171abe
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package org.libreoffice.report.pentaho.styles;
20 /**
21 * A hash key for the stylemapper.
23 * @since 12.03.2007
25 public final class StyleMapperKey
28 private final String elementNamespace;
29 private final String elementName;
30 private final String attributeNamespace;
31 private final String attributeName;
32 private final int hashCode;
34 public StyleMapperKey(final String elementNamespace,
35 final String elementName,
36 final String attributeNamespace,
37 final String attributeName)
39 if (elementNamespace == null)
41 throw new NullPointerException();
43 if (elementName == null)
45 throw new NullPointerException();
48 this.elementNamespace = elementNamespace;
49 this.elementName = elementName;
50 this.attributeNamespace = attributeNamespace;
51 this.attributeName = attributeName;
52 this.hashCode = computeHashCode();
55 @Override
56 public boolean equals(final Object o)
58 if (this != o)
60 if (o == null || getClass() != o.getClass())
62 return false;
65 final StyleMapperKey that = (StyleMapperKey) o;
67 if ((attributeName != null ? !attributeName.equals(that.attributeName) : that.attributeName != null) || (attributeNamespace != null ? !attributeNamespace.equals(that.attributeNamespace) : that.attributeNamespace != null) || !elementName.equals(that.elementName) || !elementNamespace.equals(that.elementNamespace))
69 return false;
73 return true;
76 private int computeHashCode()
78 int result = elementNamespace.hashCode();
79 result = 31 * result + elementName.hashCode();
80 result = 31 * result + (attributeNamespace != null ? attributeNamespace.hashCode() : 0);
81 result = 31 * result + (attributeName != null ? attributeName.hashCode() : 0);
82 return result;
85 @Override
86 public int hashCode()
88 return hashCode;