Transform a path address.

@param original the path address to be transformed
@param target the transformation target
@return the transformed path address
967142
protected static PathAddress transformAddress(final PathAddress original, final TransformationTarget target) {
        final List<PathAddressTransformer> transformers = target.getPathTransformation(original);
        final Iterator<PathAddressTransformer> transformations = transformers.iterator();
        final PathAddressTransformer.BuilderImpl builder = new PathAddressTransformer.BuilderImpl(transformations, original);
        return builder.start();
    }
1019231
public static <T> T convertIfNecessary(Object target, Class<T> type) {
        if (type.isInstance(target)) {
            return type.cast(target);
        }

        if (Source.class.isAssignableFrom(type)) {
            if (target.getClass().isAssignableFrom(String.class)) {
                return (T) new StringSource(String.valueOf(target));
            } else if (target.getClass().isAssignableFrom(Node.class)) {
                return (T) new DOMSource((Node) target);
            } else if (target.getClass().isAssignableFrom(InputStreamSource.class)) {
                try {
                    return (T) new StreamSource(((InputStreamSource)target).getInputStream());
                } catch (IOException e) {
                    log.warn("Failed to create stream source from object", e);
                }
            }
        }

        if (MultiValueMap.class.isAssignableFrom(type)) {
            String mapString = String.valueOf(target);

            Properties props = new Properties();
            try {
                props.load(new StringReader(mapString.substring(1, mapString.length() - 1).replaceAll("\\]\\s*", "]\n")));
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to reconstruct object of type map", e);
            }
            MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
            for (Map.Entry<Object, Object> entry : props.entrySet()) {
                String arrayString = String.valueOf(entry.getValue()).replaceAll("^\\[", "").replaceAll("\\]$", "").replaceAll(",\\s", ",");
                map.add(entry.getKey().toString(), StringUtils.commaDelimitedListToStringArray(String.valueOf(arrayString)));
            }

            return (T) map;
        }

        if (Map.class.isAssignableFrom(type)) {
            String mapString = String.valueOf(target);

            Properties props = new Properties();
            try {
                props.load(new StringReader(mapString.substring(1, mapString.length() - 1).replaceAll(",\\s*", "\n")));
            } catch (IOException e) {
                throw new CitrusRuntimeException("Failed to reconstruct object of type map", e);
            }
            Map<String, Object> map = new LinkedHashMap<>();
            for (Map.Entry<Object, Object> entry : props.entrySet()) {
                map.put(entry.getKey().toString(), entry.getValue());
            }

            return (T) map;
        }

        if (String[].class.isAssignableFrom(type)) {
            String arrayString = String.valueOf(target).replaceAll("^\\[", "").replaceAll("\\]$", "").replaceAll(",\\s", ",");
            return (T) StringUtils.commaDelimitedListToStringArray(String.valueOf(arrayString));
        }

        if (List.class.isAssignableFrom(type)) {
            String listString = String.valueOf(target).replaceAll("^\\[", "").replaceAll("\\]$", "").replaceAll(",\\s", ",");
            return (T) Arrays.asList(StringUtils.commaDelimitedListToStringArray(String.valueOf(listString)));
        }

        if (byte[].class.isAssignableFrom(type)) {
            if (target instanceof String) {
                try {
                    return (T) String.valueOf(target).getBytes(Citrus.CITRUS_FILE_ENCODING);
                } catch (UnsupportedEncodingException e) {
                    return (T) String.valueOf(target).getBytes();
                }
            } else if (target instanceof ByteBuffer) {
                return (T) ((ByteBuffer) target).array();
            } else if (target instanceof ByteArrayInputStream) {
                try {
                    return (T) StreamUtils.copyToByteArray((ByteArrayInputStream) target);
                } catch (IOException e) {
                    throw new CitrusRuntimeException("Failed to convert input stream to byte[]");
                }
            }
        }

        if (InputStream.class.isAssignableFrom(type)) {
            if (target instanceof InputStream) {
                return (T) target;
            } else if (target instanceof byte[]) {
                return (T) new ByteArrayInputStream((byte[]) target);
            } else if (target instanceof String) {
                try {
                    return (T) new ByteArrayInputStream(String.valueOf(target).getBytes(Citrus.CITRUS_FILE_ENCODING));
                } catch (UnsupportedEncodingException e) {
                    return (T) new ByteArrayInputStream(String.valueOf(target).getBytes());
                }
            } else {
                try {
                    return (T) new ByteArrayInputStream(target.toString().getBytes(Citrus.CITRUS_FILE_ENCODING));
                } catch (UnsupportedEncodingException e) {
                    return (T) new ByteArrayInputStream(target.toString().getBytes());
                }
            }
        }
597255
public String getFileName(String originalFileName) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_targetFileName)) {
            return m_targetFileName;
        } else if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_targetFileNamePrefix)) {
            return m_targetFileNamePrefix + originalFileName;
        } else {
            return originalFileName;
        }
    }
499422
public MethodlessRouter<T> addRoute(String pathPattern, T target) {
		PathPattern p = new PathPattern(pathPattern);
		if (routes.containsKey(p)) {
			return this;
		}

		routes.put(p, target);
		return this;
	}
623272
public static TreePath getPath(TreePath path, Tree target) {
        path.getClass();
        target.getClass();

        class Result extends Error {
            static final long serialVersionUID = -5942088234594905625L;
            TreePath path;
            Result(TreePath path) {
                this.path = path;
            }
        }

        class PathFinder extends TreePathScanner<TreePath,Tree> {
            public TreePath scan(Tree tree, Tree target) {
                if (tree == target) {
                    throw new Result(new TreePath(getCurrentPath(), target));
                }
                return super.scan(tree, target);
            }
        }

        if (path.getLeaf() == target) {
            return path;
        }

        try {
            new PathFinder().scan(path, target);
        } catch (Result result) {
            return result.path;
        }
        return null;
    }
109376
public NonorderedRouter<T> pattern(String path, T target) {
    final Pattern<T> pattern = new Pattern<T>(path, target);
    patterns.add(pattern);

    List<Pattern<T>> patterns = reverse.get(target);
    if (patterns == null) {
      patterns = new ArrayList<Pattern<T>>();
      patterns.add(pattern);
      reverse.put(target, patterns);
    } else {
      patterns.add(pattern);
    }

    return this;
  }
1321579
private static String targetToString(Object target) {
		if (target instanceof Class) {
			return ((Class<?>) target).getName();
		} else {
			return target.toString();
		}
	}
263391
private OtterTransformer lookup(DataMedia sourceDataMedia, DataMedia targetDataMedia) {
        if (sourceDataMedia instanceof DbDataMedia && targetDataMedia instanceof DbDataMedia) {
            return rowDataTransformer;
        }

        throw new TransformException("no support translate for source " + sourceDataMedia.toString() + " to target "
                                     + targetDataMedia);
    }
1363521
public static Object getValue(Object target, String dPath) {
        if (target instanceof JsonNode) {
            return getValue((JsonNode) target, dPath);
        }
        String[] paths = splitDpath(dPath);
        Object result = target;
        for (String path : paths) {
            result = extractValue(result, path);
        }
        return result instanceof POJONode ? extractValue((POJONode) result) : result;
    }
1177326
public static QueryParameters updateDirections(QueryParameters original, QueryParameters source) {
        QueryParameters updatedParams = new QueryParameters(original);
        Integer position = null;
        String originalKey = null;

        if (source != null) {
            for (String sourceKey : source.keySet()) {
                position = source.getFirstPosition(sourceKey);

                if (position != null) {
                    originalKey = original.getNameByPosition(position);
                    if (updatedParams.containsKey(originalKey) == true) {
                        updatedParams.updateDirection(originalKey, source.getDirection(sourceKey));
                    }
                }
            }
        }

        return updatedParams;
    }
895966
@Override
    public T move(ArchivePath source, ArchivePath target) throws IllegalArgumentException, IllegalArchivePathException {
        Validate.notNull(source, "The source path was not specified");
        Validate.notNull(target, "The target path was not specified");

        final Node nodeToMove = get(source);
        if (null == nodeToMove) {
           throw new IllegalArchivePathException(source.get() + " doesn't specify any node in the archive to move");
        }
        final Asset asset = nodeToMove.getAsset();
        // Directory?
        if (asset == null) {
            this.addAsDirectory(target);
        } else {
            add(asset, target);
        }

        // move children
        final Set<Node> nodeToMoveChildren = nodeToMove.getChildren();
        for (final Node child : nodeToMoveChildren) {
            final String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), "");
            final ArchivePath childTargetPath = ArchivePaths.create(target, childName);
            move(child.getPath(), childTargetPath);
        }

        delete(source);

        return covariantReturn();
    }
692311
public static Map<String, Object> resolveTo(Map<String, Object> root, Map<String, Object> target)
	{
		resolve(target, root, "");
		return target;
	}
1343663
public String resolveRelativePath(String source, String target) {

        String result = null;
        if (target.startsWith(".")) {
            if (target.startsWith("./")) {
                target = target.substring(2);
            }
            while (target.startsWith("../")) {
                source = CmsResource.getParentFolder(source);
                target = target.substring(3);
            }
            result = CmsStringUtil.joinPaths(source, target);
        } else {
            result = target;
        }
        return result;
    }
469769
public static String replaceCRToken(final String original) {
        String toReplace = original;

        if (original != null && original.indexOf(NEWLINE_TOKEN) >= 0) {
            toReplace = StringUtil.replace(NEWLINE_TOKEN, NEW_LINE, original);
        }

        return toReplace;
    }
863384
public static Filter<Link> adaptFilterURI2Link(final Filter<URI> original) {
		return new AbstractFilter<Link>() {
			@Override
			public boolean apply(final Link link) {
				return original.apply(link.target);
			}
			@Override
			public String toString() {
				return original.toString();
			}
			@Override
			public Filter<Link> copy() {
				return adaptFilterURI2Link(original.copy());
			}
		};
	}
1248297
private <T> Collection<Integer> transformSink(SinkTransformation<T> sink) {

		Collection<Integer> inputIds = transform(sink.getInput());

		String slotSharingGroup = determineSlotSharingGroup(sink.getSlotSharingGroup(), inputIds);

		streamGraph.addSink(sink.getId(),
				slotSharingGroup,
				sink.getCoLocationGroupKey(),
				sink.getOperator(),
				sink.getInput().getOutputType(),
				null,
				"Sink: " + sink.getName());

		streamGraph.setParallelism(sink.getId(), sink.getParallelism());
		streamGraph.setMaxParallelism(sink.getId(), sink.getMaxParallelism());

		for (Integer inputId: inputIds) {
			streamGraph.addEdge(inputId,
					sink.getId(),
					0
			);
		}

		if (sink.getStateKeySelector() != null) {
			TypeSerializer<?> keySerializer = sink.getStateKeyType().createSerializer(env.getConfig());
			streamGraph.setOneInputStateKey(sink.getId(), sink.getStateKeySelector(), keySerializer);
		}

		return Collections.emptyList();
	}
936691
public <P> Q innerJoin(Path<? extends Collection<P>> target, Path<P> alias) {
        getMetadata().addJoin(JoinType.INNERJOIN, createAlias(target, alias));
        return queryMixin.getSelf();
    }