Java tutorial
/** * Copyright Vclav Brodec 2014. * * This file is part of Botn?ek. * * Botn?ek is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Botn?ek 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Botn?ek. If not, see <http://www.gnu.org/licenses/>. */ package cz.cuni.mff.ms.brodecva.botnicek.ide.utils.data.graphs; import java.util.Set; import com.google.common.base.Preconditions; import com.google.common.collect.Sets; /** * Orientace hrany grafu v?i uzlu. * * @author Vclav Brodec * @version 1.0 */ /** * @author Vclav Brodec * @version 1.0 */ public enum Direction { /** * Hran smujc do uzlu. */ IN, /** * Hrana smujc z uzlu. */ OUT; /** * Vrt opa?nou orientaci. * * @param direction * orientace * @return opa?n orientace */ public static Direction getOpposite(final Direction direction) { Preconditions.checkNotNull(direction); final Direction[] values = values(); assert values.length == 2; final Set<Direction> valuesSet = Sets.newHashSet(values); valuesSet.remove(direction); return valuesSet.iterator().next(); } /** * Vrt opa?nou orientaci. * * @return opa?n orientace */ public Direction getOpposite() { return getOpposite(this); } }