import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
class Scratch {
public static void main(String[] args) {
String[] shops = {"DE", "CH", "AT", "NL", "FR", "DK", "ES", "IT", "EN", "SE", "NO", "FI", "PT", "BE", "LU", "RO", "GR", "CZ", "PL", "HU"};
List<String> shopList = Arrays.asList(shops);
Collections.shuffle(shopList);
String result = shopList.stream().limit(5).collect(Collectors.joining("+"));
System.out.println(result);
}
}
<div [hidden]="true">
<ngx-datatable #dataTable
[rows]="[]"
[columns]="[]">
</ngx-datatable>
</div>
export class RootComponent implements OnInit{
@ViewChild('dataTable') dataTable: DatatableComponent;
ngOnInit(): void {
Object.getPrototypeOf(this.dataTable.bodyComponent).updatePage = () => {
console.log("Skip Update Page")
};
}
}
public static void main(String[] args) {
Map<String, List<Object>> map = new LinkedHashMap<>();
map.put("field1", Arrays.asList(1, 2, 3));
map.put("field2", Arrays.asList(true, false, true));
map.put("field3", Arrays.asList("123", "456", "789"));
map.put("field4", Arrays.asList(3, 2, 1));
List<Map<String, Object>> result = IntStream.range(0, map.values().iterator().next().size())
.mapToObj(index -> {
Map<String, Object> test = new LinkedHashMap<>();
map.forEach((s, objects) -> test.put(s, objects.get(index)));
return test;
}).collect(Collectors.toList());
System.out.println(result);
}
{
"login": "josh",
"id": 137,
"avatar_url": "https://avatars.githubusercontent.com/u/137?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/josh",
"html_url": "https://github.com/josh",
"followers_url": "https://api.github.com/users/josh/followers",
"following_url": "https://api.github.com/users/josh/following{/other_user}",
"gists_url": "https://api.github.com/users/josh/gists{/gist_id}",
"starred_url": "https://api.github.com/users/josh/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/josh/subscriptions",
"organizations_url": "https://api.github.com/users/josh/orgs",
"repos_url": "https://api.github.com/users/josh/repos",
"events_url": "https://api.github.com/users/josh/events{/privacy}",
"received_events_url": "https://api.github.com/users/josh/received_events",
"type": "User",
"site_admin": true
},
public interface InitCallback {
void init();
class Http implements InitCallback {
void sendData(String url, SuccessCallback success, FailureCallback fail) {
try {
//Делаем реквест
String httpResult = "200";
//Вызываекм коллбек
success.success(httpResult);
} catch (Exception ex) {
//Вызываекм коллбек в случае ошибки
fail.fail("400");
}
}
public void init() {
System.out.println("Вызван init коллбек");
}
interface SuccessCallback {
void success(String result);
}
interface FailureCallback {
void fail(String error);
}
public static void main(String[] args) {
Http http = new Http();
if (http instanceof InitCallback) {
//Если это наш интерфес, то вызываем колбек
http.init();
}
http.sendData("/my/api", new SuccessCallback() {
@Override
public void success(String result) {
System.out.println("Успешный колбек: " + result);
}
}, new FailureCallback() {
@Override
public void fail(String error) {
System.out.println("Колбек вернул ошибку: " + error);
}
});
}
}
}
@RequestMapping(path = {"film/*", "serial/*"}, method = RequestMethod.GET)
public String index() {
return "forward:/index.html";
}
@RestController
@RequestMapping("/rest/content")
public class ContentController {
@RequestMapping(method = RequestMethod.GET)
public HttpStatus searchContent(@Param("name") String name) {
System.out.println("search for content with param: " + name);
return HttpStatus.ACCEPTED;
}
@RequestMapping(method = RequestMethod.POST)
public HttpStatus uploadContent(@RequestBody Content content) {
System.out.println("upload content");
return upload != null ? HttpStatus.CREATED : HttpStatus.BAD_REQUEST;
}
}