1 /* 2 * This file is part of Arduino. 3 * 4 * Copyright 2014 Arduino LLC (http://www.arduino.cc/) 5 * 6 * Arduino is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 * As a special exception, you may use this file as part of a free software 21 * library without restriction. Specifically, if other files instantiate 22 * templates or use macros or inline functions from this file, or you compile 23 * this file and link it with other files to produce an executable, this 24 * file does not by itself cause the resulting executable to be covered by 25 * the GNU General Public License. This exception does not however 26 * invalidate any other reasons why the executable file might be covered by 27 * the GNU General Public License. 28 */ 29 30 package cc.arduino.contributions.packages; 31 32 import cc.arduino.contributions.DownloadableContribution; 33 import processing.app.Platform; 34 35 import java.util.List; 36 37 public abstract class ContributedTool { 38 getName()39 public abstract String getName(); 40 getVersion()41 public abstract String getVersion(); 42 getSystems()43 public abstract List<HostDependentDownloadableContribution> getSystems(); 44 45 private ContributedPackage contributedPackage; 46 getPackage()47 public ContributedPackage getPackage() { 48 return contributedPackage; 49 } 50 setPackage(ContributedPackage pack)51 public void setPackage(ContributedPackage pack) { 52 contributedPackage = pack; 53 } 54 getPackager()55 public String getPackager() { 56 return contributedPackage.getName(); 57 } 58 getDownloadableContribution(Platform platform)59 public DownloadableContribution getDownloadableContribution(Platform platform) { 60 for (HostDependentDownloadableContribution c : getSystems()) { 61 if (c.isCompatible(platform)) 62 return c; 63 } 64 return null; 65 } 66 67 @Override toString()68 public String toString() { 69 return toString(null); 70 } 71 toString(Platform platform)72 public String toString(Platform platform) { 73 String res; 74 res = "Tool name : " + getName() + " " + getVersion() + "\n"; 75 for (HostDependentDownloadableContribution sys : getSystems()) { 76 res += " sys"; 77 if (platform != null) { 78 res += sys.isCompatible(platform) ? "*" : " "; 79 } 80 res += " : " + sys + "\n"; 81 } 82 return res; 83 } 84 85 @Override equals(Object obj)86 public boolean equals(Object obj) { 87 if (obj == null) { 88 return false; 89 } 90 if (!(obj instanceof ContributedTool)) { 91 return false; 92 } 93 94 ContributedTool obj1 = (ContributedTool) obj; 95 return getName().equals(obj1.getName()) && getVersion().equals(obj1.getVersion()); 96 } 97 } 98