001/*license*\ 002 Codelet: Copyright (C) 2014, Jeff Epstein (aliteralmind __DASH__ github __AT__ yahoo __DOT__ com) 003 004 This software is dual-licensed under the: 005 - Lesser General Public License (LGPL) version 3.0 or, at your option, any later version; 006 - Apache Software License (ASL) version 2.0. 007 008 Either license may be applied at your discretion. More information may be found at 009 - http://en.wikipedia.org/wiki/Multi-licensing. 010 011 The text of both licenses is available in the root directory of this project, under the names "LICENSE_lgpl-3.0.txt" and "LICENSE_asl-2.0.txt". The latest copies may be downloaded at: 012 - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt 013 - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt 014\*license*/ 015package com.github.aliteralmind.codelet.examples.simplesig; 016 import com.github.aliteralmind.codelet.simplesig.AllSimpleParamSignatures; 017 import com.github.aliteralmind.codelet.simplesig.MethodSigSearchTerm; 018 import com.github.aliteralmind.codelet.simplesig.MethodSimpleParamSig; 019 import com.github.aliteralmind.codelet.simplesig.CrashIfMoreThanOne; 020 import com.github.aliteralmind.codelet.simplesig.CrashIfZero; 021 import com.github.xbn.lang.reflect.Declared; 022 import java.util.List; 023/** 024 <p>Demonstration of {@link com.github.aliteralmind.codelet.simplesig.MethodSigSearchTerm}.</p> 025 026 <p>{@code java com.github.aliteralmind.codelet.examples.simplesig.MethodSigSearchTermXmpl}</p> 027 028 * @since 0.1.0 029 * @author Copyright (C) 2014, Jeff Epstein ({@code aliteralmind __DASH__ github __AT__ yahoo __DOT__ com}), dual-licensed under the LGPL (version 3.0 or later) or the ASL (version 2.0). See source code for details. <a href="http://codelet.aliteralmind.com">{@code http://codelet.aliteralmind.com}</a>, <a href="https://github.com/aliteralmind/codelet">{@code https://github.com/aliteralmind/codelet}</a> 030 **/ 031 032public class MethodSigSearchTermXmpl { 033 public static final String LINE_SEP = System.getProperty("line.separator", "\r\n"); 034 public static final void main(String[] ignored) { 035 036 AllSimpleParamSignatures allInClass = new AllSimpleParamSignatures( 037 MethodSigSearchTermXmpl.class, Declared.NO); 038 039 test(allInClass, "nonExisting()"); 040 test(allInClass, "doSomething()"); 041 test(allInClass, "doSomething(*)"); 042 test(allInClass, "doSomething(*,byte,*)"); 043 } 044 private static void test(AllSimpleParamSignatures all_inClass, String param_searchTerm) { 045 046 MethodSigSearchTerm searchTerm = new MethodSigSearchTerm(param_searchTerm, null, null); 047 048 System.out.println("Searching for: \"" + param_searchTerm + "\""); 049 050 if(!searchTerm.doesMatchAny(all_inClass)) { 051 System.out.println(" Not found."); 052 System.out.println(); 053 return; 054 } 055 056 MethodSimpleParamSig first = searchTerm.getFirstMatch( 057 all_inClass, CrashIfZero.NO, CrashIfMoreThanOne.NO); 058 059 List<MethodSimpleParamSig> allMatches = searchTerm.getAllMatches( 060 all_inClass, CrashIfZero.NO); 061 062 System.out.println(" - First match: " + first); 063 System.out.println(" - All matches:" + LINE_SEP + 064 AllSimpleParamSignatures.toStringForAllListsInList(" - ", allMatches, LINE_SEP)); 065 066 System.out.println(); 067 } 068 public String doSomething(String s, boolean b, int i, Object o) { 069 return null; 070 } 071 public String doSomething(String s, boolean b, int[] i, byte y, Object o) { 072 return null; 073 } 074}