blob: 5978a324f4d39172523109a72e1e7856024f248c [file] [log] [blame]
/*
*
* Copyright (c) 2011 - 2017 - Loetz GmbH & Co KG, 69115 Heidelberg, Germany
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Initial contribution:
* Loetz GmbH & Co. KG
*
*/
package org.eclipse.osbp.ui.api.datamart;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.osbp.runtime.common.event.IDualData;
/**
* The Class DatamartData.
*/
@XmlRootElement
public class DatamartData implements IDualData {
private String selectionValue;
private String formattedValue;
private String hierarchy = null;
@XmlElement
private boolean isString = false;
@Override
public void asString(boolean isString) {
this.isString = isString;
}
@Override
public String getDatabaseSelectionValue() {
if(isString) {
return "'"+selectionValue.replace("'", "''")+"'";
}
return selectionValue;
}
@XmlElement
@Override
public void setSelectionValue(String selectionValue) {
this.selectionValue = selectionValue;
}
@Override
public String getSelectionValue() {
return selectionValue;
}
@XmlElement
@Override
public void setFormattedValue(String formattedValue) {
this.formattedValue = formattedValue;
}
@Override
public String getFormattedValue() {
return formattedValue;
}
@XmlElement
@Override
public void setHierarchy(String hierarchy) {
this.hierarchy = hierarchy;
}
@Override
public String getHierarchy() {
return hierarchy;
}
@Override
public String getHierarchyWithBrackets() {
if (hierarchy != null) {
return "[" + hierarchy + "]";
}
return "";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((formattedValue == null) ? 0 : formattedValue.hashCode());
result = prime * result + ((hierarchy == null) ? 0 : hierarchy.hashCode());
result = prime * result + (isString ? 1231 : 1237);
result = prime * result + ((selectionValue == null) ? 0 : selectionValue.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DatamartData)) {
return false;
}
DatamartData other = (DatamartData) obj;
if (formattedValue == null) {
if (other.formattedValue != null) {
return false;
}
} else if (!formattedValue.equals(other.formattedValue)) {
return false;
}
if (hierarchy == null) {
if (other.hierarchy != null) {
return false;
}
} else if (!hierarchy.equals(other.hierarchy)) {
return false;
}
if (isString != other.isString) {
return false;
}
if (selectionValue == null) {
if (other.selectionValue != null) {
return false;
}
} else if (!selectionValue.equals(other.selectionValue)) {
return false;
}
return true;
}
}