# Class ParameterFinder<P extends uk.ac.starlink.task.Parameter<?>>

java.lang.Object
uk.ac.starlink.ttools.plot2.task.ParameterFinder<P>

public abstract class ParameterFinder<P extends uk.ac.starlink.task.Parameter<?>> extends Object
Used for obtaining a parameter qualified by an optional suffix.

In some cases, it is desirable to allow parameters which are logically associated with a layer suffix to be specified without the suffix, for instance if you have three layers using the same table `x`, it's nice to write "`in=x`" as a shorthand for "`in1=x in2=x in3=x`". But if `in2=x` is present in the environment, that will be used in preference.

Since:
  2 Sep 2014
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`ParameterFinder()`

## Method Summary

Modifier and Type
Method
Description
`abstract P`
`createParameter(String suffix)`
Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.
`P`
`findParameter(uk.ac.starlink.task.Environment env, String fullSuffix)`
Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment.
`P`
`findParameterByName(String target, String fullSuffix)`
Attempts to locate a parameter known by this finder with the given name.
`P`
`getParameter(uk.ac.starlink.task.Environment env, String fullSuffix)`
Calls `findParameter(Environment, String)`, but if the result is null, a parameter with the full suffix is returned.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ParameterFinder

public ParameterFinder()

## Method Details

### createParameter

public abstract P createParameter(String suffix)
Concrete subclasses must implement this method to create a parameter of the right type with an arbitrary suffix.

Parameters:
  `suffix` - arbitrary suffix
Returns:
  parameter of with the given suffix

### getParameter

public P getParameter(uk.ac.starlink.task.Environment env, String fullSuffix)
Calls `findParameter(Environment, String)`, but if the result is null, a parameter with the full suffix is returned. In that case, the environment doesn't already have a value for the parameter, but it may take steps to obtain one (like asking the user).

Parameters:
  `env` - execution environment, possibly populated with values
  `fullSuffix` - suffix associated with the layer for which the value is required
Returns:
  parameter for obtaining a value associated with the layer suffix, not null

### findParameter

public P findParameter(uk.ac.starlink.task.Environment env, String fullSuffix)
Returns an existing parameter to use for obtaining a value associated with the given layer suffix from the given environment. If the environment contains a value for the parameter with the given suffix, or of any shortened form of that suffix (including the empty string), that parameter is returned. Otherwise, null is returned.

Parameters:
  `env` - execution environment, possibly populated with values
  `fullSuffix` - suffix associated with the layer for which the value is required
Returns:
  parameter for obtaining a value associated with the layer suffix, or null

### findParameterByName

public P findParameterByName(String target, String fullSuffix)
Attempts to locate a parameter known by this finder with the given name. If it can't be found, return null.

Parameters:
  `target` - required parameter name (not case-sensitive)
  `fullSuffix` - suffix associated with the layer for which the value is required
Returns:
  parameter with name `target`, or null