All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.source.formatter.SourceFormatterMessage Maven / Gradle / Ivy

There is a newer version: 1.0.1437
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.source.formatter;

import com.liferay.portal.kernel.util.NaturalOrderStringComparator;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;

/**
 * @author Hugo Huijser
 */
public class SourceFormatterMessage
	implements Comparable {

	public SourceFormatterMessage(String fileName, String message) {
		this(fileName, message, -1);
	}

	public SourceFormatterMessage(
		String fileName, String message, int lineCount) {

		_fileName = fileName;
		_message = message;
		_lineCount = lineCount;
	}

	@Override
	public int compareTo(SourceFormatterMessage sourceFormatterMessage) {
		NaturalOrderStringComparator naturalOrderStringComparator =
			new NaturalOrderStringComparator();

		return naturalOrderStringComparator.compare(
			toString(), sourceFormatterMessage.toString());
	}

	public String getFileName() {
		return _fileName;
	}

	public int getLineCount() {
		return _lineCount;
	}

	public String getMessage() {
		return _message;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(5);

		sb.append(_message);
		sb.append(": ");
		sb.append(_fileName);

		if (_lineCount > -1) {
			sb.append(StringPool.SPACE);
			sb.append(_lineCount);
		}

		return sb.toString();
	}

	private final String _fileName;
	private final int _lineCount;
	private final String _message;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy