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

org.eclipse.epsilon.egl.patch.TextBlock Maven / Gradle / Ivy

The newest version!
/*********************************************************************
* Copyright (c) 2008 The University of York.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.epsilon.egl.patch;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @since 1.6
 */
public class TextBlock {
	
	protected List lines = new ArrayList<>();
	
	public TextBlock(String... lines) {
		for (int i=0; i getLines() {
		return lines;
	}
	
	protected boolean isFirstLine(Line line) {
		if (line == null) return false;
		return lines.indexOf(line) == 0;
	}
	
	protected boolean isLastLine(Line line) {
		if (line == null) return false;
		return lines.indexOf(line) == lines.size() - 1;
	}
	
	protected Line getPreviousLine(Line line) {
		if (isFirstLine(line)) return null;
		else return lines.get(lines.indexOf(line) - 1);
	}
	
	protected Line getNextLine(Line line) {
		if (isLastLine(line)) return null;
		else return lines.get(lines.indexOf(line) + 1);
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof TextBlock)) return false;
		TextBlock other = (TextBlock) obj;
		if (other.getLines().size() != this.getLines().size()) return false;
		for (int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy