Skip to content
Snippets Groups Projects
Commit bf1e9ad2 authored by tpylak's avatar tpylak
Browse files

LMS-2562 minor: improve toString method

SVN: 23548
parent bf0c013a
No related branches found
No related tags found
No related merge requests found
...@@ -23,9 +23,9 @@ import java.util.List; ...@@ -23,9 +23,9 @@ import java.util.List;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import ch.systemsx.cisd.common.Constants;
import ch.systemsx.cisd.common.types.BooleanOrUnknown; import ch.systemsx.cisd.common.types.BooleanOrUnknown;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.SpeedUtils; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.SpeedUtils;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.ToStringUtil;
import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.IServer;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment;
...@@ -395,8 +395,6 @@ public class DataSetInformation implements Serializable ...@@ -395,8 +395,6 @@ public class DataSetInformation implements Serializable
} }
appendNameAndObject(buffer, "Experiment Identifier", getExperimentIdentifier()); appendNameAndObject(buffer, "Experiment Identifier", getExperimentIdentifier());
appendNameAndObject(buffer, "Sample Identifier", getSampleIdentifier()); appendNameAndObject(buffer, "Sample Identifier", getSampleIdentifier());
appendNameAndObject(buffer, "Producer Code", getProducerCode());
appendNameAndObject(buffer, "Production Date", formatDate(getProductionDate()));
final List<String> parentDataSetCodes = getParentDataSetCodes(); final List<String> parentDataSetCodes = getParentDataSetCodes();
if (parentDataSetCodes.isEmpty() == false) if (parentDataSetCodes.isEmpty() == false)
{ {
...@@ -408,17 +406,9 @@ public class DataSetInformation implements Serializable ...@@ -408,17 +406,9 @@ public class DataSetInformation implements Serializable
return buffer.toString(); return buffer.toString();
} }
private static String formatDate(Date productionDate)
{
return productionDate == null ? "" : Constants.DATE_FORMAT.get().format(productionDate);
}
protected static final void appendNameAndObject(final StringBuilder buffer, final String name, protected static final void appendNameAndObject(final StringBuilder buffer, final String name,
final Object object) final Object object)
{ {
if (object != null) ToStringUtil.appendNameAndObject(buffer, name, object);
{
buffer.append(name).append("::").append(object).append(";");
}
} }
} }
\ No newline at end of file
/*
* Copyright 2011 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.dss.generic.shared.utils;
/**
* @author Tomasz Pylak
*/
public class ToStringUtil
{
/** Helps in implementing toString() methods */
public static final void appendNameAndObject(final StringBuilder buffer, final String name,
final Object object)
{
if (object != null)
{
buffer.append(name).append("::").append(object).append(";");
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment