MCPcopy Index your code
hub / github.com/aws/jsii / validateArray

Method validateArray

packages/jsii-pacmak/lib/targets/java.ts:1837–1869  ·  view source on GitHub ↗
(
      this: JavaGenerator,
      value: string,
      descr: string,
      elementType: spec.TypeReference,
      parameterName: string,
      isRawArray: boolean,
    )

Source from the content-addressed store, hash-verified

1835 }
1836
1837 function validateArray(
1838 this: JavaGenerator,
1839 value: string,
1840 descr: string,
1841 elementType: spec.TypeReference,
1842 parameterName: string,
1843 isRawArray: boolean,
1844 ) {
1845 const suffix = createHash('sha256')
1846 .update(descr)
1847 .digest('hex')
1848 .slice(0, 6);
1849 const idxName = `__idx_${suffix}`;
1850 const valName = `__val_${suffix}`;
1851 this.code.openBlock(
1852 `for (int ${idxName} = 0; ${idxName} < ${value}.size(); ${idxName}++)`,
1853 );
1854 const eltType = this.toSingleJavaType(elementType);
1855 this.code.line(
1856 `final ${displayStatic(eltType)} ${valName} = ${value}.get(${idxName});`,
1857 );
1858 validate.call(
1859 this,
1860 valName,
1861 isRawArray
1862 ? `${descr}.append("[").append(${idxName}).append("]")`
1863 : `${descr}.append(".get(").append(${idxName}).append(")")`,
1864 elementType,
1865 parameterName,
1866 false,
1867 );
1868 this.code.closeBlock();
1869 }
1870
1871 function validateMap(
1872 this: JavaGenerator,

Callers

nothing calls this directly

Calls 6

toSingleJavaTypeMethod · 0.95
displayStaticFunction · 0.85
openBlockMethod · 0.80
lineMethod · 0.80
callMethod · 0.80
closeBlockMethod · 0.80

Tested by

no test coverage detected