From 347af46aa9dd4694fa6ce76fb7f0203de6acc5da Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 4 Aug 2017 10:09:14 +0900 Subject: [PATCH] ing --- .../config/ConstructorArgumentValues.ts | 185 +++++------------- tslint.json | 2 +- 2 files changed, 52 insertions(+), 135 deletions(-) diff --git a/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts b/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts index bce972b..8607ba9 100644 --- a/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts +++ b/src/ts/@loafer/pouches/factory/config/ConstructorArgumentValues.ts @@ -108,17 +108,6 @@ export class ConstructorArgumentValues { return this.indexedArgumentValues.has(index); } - /** - * Get argument value for the given index in the constructor argument list. - * @param index the index in the constructor argument list - * @param requiredType the type to match (can be {@code null} to match - * untyped values only) - * @return the ValueHolder for the argument, or {@code null} if none set - */ - public getIndexedArgumentValue(index: number, requiredType: ClassType): ValueHolder { - return getIndexedArgumentValue(index, requiredType, null); - } - /** * Get argument value for the given index in the constructor argument list. * @param index the index in the constructor argument list @@ -128,11 +117,10 @@ export class ConstructorArgumentValues { * unnamed values only, or empty String to match any name) * @return the ValueHolder for the argument, or {@code null} if none set */ - - public getIndexedArgumentValue(index: number, requiredType: ClassType, requiredName: PropertyType): ValueHolder { - Assert.isTrue(index >= 0, "Index must not be negative"); - ValueHolder valueHolder = this.indexedArgumentValues.get(index); - if (valueHolder != null && + public getIndexedArgumentValue(index: number, requiredType: ClassType, requiredName?: PropertyType): ValueHolder { + Assert.isTrue(index >= 0, 'Index must not be negative'); + let valueHolder: ValueHolder = this.indexedArgumentValues.get(index); + if (undefined !== valueHolder && (valueHolder.getType() == null || (requiredType != null && ClassUtils.matchesTypeName(requiredType, valueHolder.getType()))) && (valueHolder.getName() == null || "".equals(requiredName) || @@ -147,7 +135,7 @@ export class ConstructorArgumentValues { * @return unmodifiable Map with Integer index as key and ValueHolder as value * @see ValueHolder */ - public Map getIndexedArgumentValues() { + public getIndexedArgumentValues(): Map { return Collections.unmodifiableMap(this.indexedArgumentValues); } @@ -158,7 +146,7 @@ export class ConstructorArgumentValues { * rather than matched multiple times. * @param value the argument value */ - public void addGenericArgumentValue(Object value) { + public addGenericArgumentValue(value: any): void { this.genericArgumentValues.add(new ValueHolder(value)); } @@ -169,7 +157,7 @@ export class ConstructorArgumentValues { * @param value the argument value * @param type the type of the constructor argument */ - public void addGenericArgumentValue(Object value, String type) { + public addGenericArgumentValue(value: any, type: string): void { this.genericArgumentValues.add(new ValueHolder(value, type)); } @@ -182,7 +170,7 @@ export class ConstructorArgumentValues { * to allow for merging and re-merging of argument value definitions. Distinct * ValueHolder instances carrying the same content are of course allowed. */ - public void addGenericArgumentValue(ValueHolder newValue) { + public addGenericArgumentValue(newValue: ValueHolder): void { Assert.notNull(newValue, "ValueHolder must not be null"); if (!this.genericArgumentValues.contains(newValue)) { addOrMergeGenericArgumentValue(newValue); @@ -194,13 +182,13 @@ export class ConstructorArgumentValues { * with the current value if demanded: see {@link org.springframework.beans.Mergeable}. * @param newValue the argument value in the form of a ValueHolder */ - private void addOrMergeGenericArgumentValue(ValueHolder newValue) { + private addOrMergeGenericArgumentValue(newValue: ValueHolder): void { if (newValue.getName() != null) { - for (Iterator it = this.genericArgumentValues.iterator(); it.hasNext();) { + for (Iterator it = this.genericArgumentValues.iterator(); it.hasNext();) { ValueHolder currentValue = it.next(); if (newValue.getName().equals(currentValue.getName())) { if (newValue.getValue() instanceof Mergeable) { - Mergeable mergeable = (Mergeable) newValue.getValue(); + Mergeable; mergeable = (Mergeable) newValue.getValue(); if (mergeable.isMergeEnabled()) { newValue.setValue(mergeable.merge(currentValue.getValue())); } @@ -217,8 +205,8 @@ export class ConstructorArgumentValues { * @param requiredType the type to match * @return the ValueHolder for the argument, or {@code null} if none set */ - - public ValueHolder getGenericArgumentValue(Class requiredType) { + + public getGenericArgumentValue(requiredType: ClassType): ValueHolder { return getGenericArgumentValue(requiredType, null, null); } @@ -229,7 +217,7 @@ export class ConstructorArgumentValues { * @return the ValueHolder for the argument, or {@code null} if none set */ - public ValueHolder getGenericArgumentValue(Class requiredType, String requiredName) { + public getGenericArgumentValue(requiredType: ClassType, requiredName: PropertyType): ValueHolder { return getGenericArgumentValue(requiredType, requiredName, null); } @@ -245,13 +233,13 @@ export class ConstructorArgumentValues { * in the current resolution process and should therefore not be returned again * @return the ValueHolder for the argument, or {@code null} if none found */ - - public ValueHolder getGenericArgumentValue( Class requiredType, String requiredName, Set usedValueHolders) { + + public getGenericArgumentValue(requiredType: ClassType, requiredName: string, usedValueHolders: Set): ValueHolder { for (ValueHolder valueHolder : this.genericArgumentValues) { if (usedValueHolders != null && usedValueHolders.contains(valueHolder)) { continue; } - if (valueHolder.getName() != null && !"".equals(requiredName) && + if (valueHolder.getName() != null && !''.equals(requiredName) && (requiredName == null || !valueHolder.getName().equals(requiredName))) { continue; } @@ -273,7 +261,7 @@ export class ConstructorArgumentValues { * @return unmodifiable List of ValueHolders * @see ValueHolder */ - public List getGenericArgumentValues() { + public getGenericArgumentValues(): ValueHolder[] { return Collections.unmodifiableList(this.genericArgumentValues); } @@ -285,8 +273,8 @@ export class ConstructorArgumentValues { * @param requiredType the parameter type to match * @return the ValueHolder for the argument, or {@code null} if none set */ - - public ValueHolder getArgumentValue(index: number, Class requiredType) { + + public getArgumentValue(index: number, requiredType: ClassType): ValueHolder { return getArgumentValue(index, requiredType, null, null); } @@ -298,8 +286,8 @@ export class ConstructorArgumentValues { * @param requiredName the parameter name to match * @return the ValueHolder for the argument, or {@code null} if none set */ - - public ValueHolder getArgumentValue(index: number, Class requiredType, String requiredName) { + + public getArgumentValue(index: number, requiredType: ClassType, requiredName: string): ValueHolder { return getArgumentValue(index, requiredType, requiredName, null); } @@ -317,10 +305,10 @@ export class ConstructorArgumentValues { * in case of multiple generic argument values of the same type) * @return the ValueHolder for the argument, or {@code null} if none set */ - - public ValueHolder getArgumentValue(index: number, Class requiredType, String requiredName, Set usedValueHolders) { - Assert.isTrue(index >= 0, "Index must not be negative"); - ValueHolder valueHolder = getIndexedArgumentValue(index, requiredType, requiredName); + + public getArgumentValue(index: number, requiredType: ClassType, requiredName: string, usedValueHolders: Set): ValueHolder { + Assert.isTrue(index >= 0, 'Index must not be negative'); + ValueHolder; valueHolder = getIndexedArgumentValue(index, requiredType, requiredName); if (valueHolder == null) { valueHolder = getGenericArgumentValue(requiredType, requiredName, usedValueHolders); } @@ -331,7 +319,7 @@ export class ConstructorArgumentValues { * Return the number of argument values held in this instance, * counting both indexed and generic argument values. */ - public int getArgumentCount() { + public getArgumentCount(): number { return (this.indexedArgumentValues.size() + this.genericArgumentValues.size()); } @@ -339,66 +327,18 @@ export class ConstructorArgumentValues { * Return if this holder does not contain any argument values, * neither indexed ones nor generic ones. */ - public boolean isEmpty() { + public isEmpty(): boolean { return (this.indexedArgumentValues.isEmpty() && this.genericArgumentValues.isEmpty()); } /** * Clear this holder, removing all argument values. */ - public void clear() { + public clear(): void { this.indexedArgumentValues.clear(); this.genericArgumentValues.clear(); } - - @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (!(other instanceof ConstructorArgumentValues)) { - return false; - } - ConstructorArgumentValues that = (ConstructorArgumentValues) other; - if (this.genericArgumentValues.size() != that.genericArgumentValues.size() || - this.indexedArgumentValues.size() != that.indexedArgumentValues.size()) { - return false; - } - Iterator it1 = this.genericArgumentValues.iterator(); - Iterator it2 = that.genericArgumentValues.iterator(); - while (it1.hasNext() && it2.hasNext()) { - ValueHolder vh1 = it1.next(); - ValueHolder vh2 = it2.next(); - if (!vh1.contentEquals(vh2)) { - return false; - } - } - for (Map.Entry entry : this.indexedArgumentValues.entrySet()) { - ValueHolder vh1 = entry.getValue(); - ValueHolder vh2 = that.indexedArgumentValues.get(entry.getKey()); - if (!vh1.contentEquals(vh2)) { - return false; - } - } - return true; - } - - @Override - public int; hashCode() { - int hashCode = 7; - for (ValueHolder valueHolder : this.genericArgumentValues) { - hashCode = 31 * hashCode + valueHolder.contentHashCode(); - } - hashCode = 29 * hashCode; - for (Map.Entry entry : this.indexedArgumentValues.entrySet()) { - hashCode = 31 * hashCode + (entry.getValue().contentHashCode() ^ entry.getKey().hashCode()); - } - return hashCode; - } - - - } @@ -407,41 +347,21 @@ export class ConstructorArgumentValues { * attribute indicating the target type of the actual constructor argument. */ export class ValueHolder implements PouchMetadataElement { + private value: any; - private Object value; + private type: string; - private String type; + private name: string; - private String name; + private source: any; + + private converted: boolean = false; - private Object source; - - private boolean converted = false; - - - private Object convertedValue; - - /** - * Create a new ValueHolder for the given value. - * @param value the argument value - */ - public ValueHolder( Object value) { - this.value = value; - } - - /** - * Create a new ValueHolder for the given value and type. - * @param value the argument value - * @param type the type of the constructor argument - */ - public ValueHolder( Object value, String type) { - this.value = value; - this.type = type; - } + private convertedValue: any; /** * Create a new ValueHolder for the given value, type and name. @@ -449,7 +369,7 @@ export class ValueHolder implements PouchMetadataElement { * @param type the type of the constructor argument * @param name the name of the constructor argument */ - public ValueHolder( Object value, String type, String name) { + public constructor( value: any, type?: string, name?: string) { this.value = value; this.type = type; this.name = name; @@ -459,7 +379,7 @@ export class ValueHolder implements PouchMetadataElement { * Set the value for the constructor argument. * @see PropertyPlaceholderConfigurer */ - public void setValue(; Object value) { + public set Value(value: any) { this.value = value; } @@ -467,14 +387,14 @@ export class ValueHolder implements PouchMetadataElement { * Return the value for the constructor argument. */ - public Object; getValue(); { + public get Value(): any { return this.value; } /** * Set the type of the constructor argument. */ - public void setType(; String; type;) { + public set Type(type: string) { this.type = type; } @@ -482,14 +402,14 @@ export class ValueHolder implements PouchMetadataElement { * Return the type of the constructor argument. */ - public String; getType(); { + public get Type(): string { return this.type; } /** * Set the name of the constructor argument. */ - public void setName(; String; name; ) { + public set Name(name: string) { this.name = name; } @@ -497,7 +417,7 @@ export class ValueHolder implements PouchMetadataElement { * Return the name of the constructor argument. */ - public String; getName(); { + public get Name(): string { return this.name; } @@ -505,13 +425,11 @@ export class ValueHolder implements PouchMetadataElement { * Set the configuration source {@code Object} for this metadata element. *

The exact type of the object will depend on the configuration mechanism used. */ - public void setSource(; Object; source; ) { + public set Source(source: any) { this.source = source; } -@Override - - public Object; getSource(); { + public get Source(): any { return this.source; } @@ -519,7 +437,7 @@ export class ValueHolder implements PouchMetadataElement { * Return whether this holder contains a converted value already ({@code true}), * or whether the value still needs to be converted ({@code false}). */ - public synchronized; boolean; isConverted(); { + public isConverted(): boolean { return this.converted; } @@ -527,7 +445,7 @@ export class ValueHolder implements PouchMetadataElement { * Set the converted value of the constructor argument, * after processed type conversion. */ - public synchronized; void setConvertedValue(; Object; value; ) { + public set ConvertedValue(value: any) { this.converted = (value != null); this.convertedValue = value; } @@ -536,8 +454,7 @@ export class ValueHolder implements PouchMetadataElement { * Return the converted value of the constructor argument, * after processed type conversion. */ - - public synchronized; Object; getConvertedValue(); { + public get ConvertedValue(): any { return this.convertedValue; } @@ -548,7 +465,7 @@ export class ValueHolder implements PouchMetadataElement { * directly, to allow for multiple ValueHolder instances with the * same content to reside in the same Set. */ - private boolean; contentEquals(ValueHolder other); { + private contentEquals(other: ValueHolder): boolean { return (this === other || (ObjectUtils.nullSafeEquals(this.value, other.value) && ObjectUtils.nullSafeEquals(this.type, other.type))); } @@ -559,7 +476,7 @@ export class ValueHolder implements PouchMetadataElement { * directly, to allow for multiple ValueHolder instances with the * same content to reside in the same Set. */ - private int; contentHashCode(); { + private contentHashCode(): number { return ObjectUtils.nullSafeHashCode(this.value) * 29 + ObjectUtils.nullSafeHashCode(this.type); } @@ -567,7 +484,7 @@ export class ValueHolder implements PouchMetadataElement { * Create a copy of this ValueHolder: that is, an independent * ValueHolder instance with the same contents. */ - public ValueHolder; copy(); { + public copy(): ValueHolder { ValueHolder; copy = new ValueHolder(this.value, this.type, this.name); copy.setSource(this.source); return copy; diff --git a/tslint.json b/tslint.json index 8cb9e85..05b0571 100644 --- a/tslint.json +++ b/tslint.json @@ -19,7 +19,7 @@ "max-line-length": [true, 140], "member-access": true, "member-ordering": [ - true, + false, { "order": [ "static-field",